Last active
March 10, 2019 14:42
-
-
Save davebrny/c8fc4dd7af299afe5ec8883faa28784a to your computer and use it in GitHub Desktop.
💬 (autohotkey) - message commands that are quick to type and easy to switch between
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msg_box(string=". . .", options="") { | |
string := format_text(string, options) | |
msgBox, % string | |
} | |
msg_tray(string=". . .", options="") { | |
string := format_text(string, options) | |
trayTip, , % string, 10 | |
} | |
msg_tool(string=". . .", options="") { | |
string := format_text(string, options) | |
toolTip, % string | |
setTimer, tool_timer, 2000 | |
} | |
msg_splash(string=". . .", options="") { | |
global msg_splash | |
msg_splash := format_text(string, options) | |
progress, b w700 zh0 c0 fs20 ws1000 ct969696, % msg_splash, , , consolas | |
setTimer, splash_timer, 2000 | |
} | |
format_text(string, options) { | |
if options is not alpha | |
{ | |
for what, with in {"1":"c", "2":"q", "3":"a"} | |
stringReplace, options, options, % what, % with, all | |
} | |
; show spaces | |
if inStr(options, "`s") | |
stringReplace, string, string, % a_space, ``s, all | |
; show tabs | |
if inStr(options, "`t") | |
stringReplace, string, string, % a_tab, ``tttt, all | |
; show linefeeds | |
obfuscate = "!su^V*3cjT#&m|Y>Ut~0J\w@s?=Qyl8-bX9a" | |
if inStr(options, "`r`n") | |
stringReplace, string, string, `r`n, % obfuscate, all | |
if inStr(options, "`n") | |
stringReplace, string, string, `n, ``n`n, all | |
if inStr(options, "`r") | |
stringReplace, string, string, `r, ``r`r, all | |
if inStr(string, obfuscate) | |
stringReplace, string, string, % obfuscate, ``r``n`r`n , all | |
; wrap text in symbols | |
linefeed := inStr(string, "`r`n") ? ("`r`n") : ("`n") | |
if inStr(options, "q") | |
{ | |
stringReplace, string, string, % linefeed, % """" linefeed """", all | |
string = "%string%" | |
} | |
else if inStr(options, "a") | |
{ | |
stringReplace, string, string, % linefeed, % "<" linefeed ">", all | |
string = >%string%< | |
} | |
; copy to clipboard | |
if inStr(options, "c") | |
clipboard = %string% | |
return string | |
} | |
tool_timer(){ | |
tool_id := winExist("ahk_class tooltips_class32") | |
mouseGetPos, , , id_under ; under cursor | |
if (id_under != tool_id) | |
{ | |
setTimer, tool_timer, off | |
toolTip, | |
} | |
} | |
splash_timer(){ | |
global msg_splash | |
mouseGetPos, , , window_under | |
winGetText, text_under, ahk_id %window_under% | |
if !inStr(text_under, msg_splash) | |
{ | |
setTimer, splash_timer, off | |
progress, off | |
} | |
} | |
/* | |
[script info] | |
version = 2.6 | |
description = message commands that are quick to type and easy to switch between | |
author = davebrny | |
source = https://gist.github.com/davebrny/c8fc4dd7af299afe5ec8883faa28784a | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::mbox:: | |
::mtray:: | |
::mtool:: | |
::msplash:: | |
stringReplace, this_label, a_thisLabel, ::m, msg_ | |
clipboard_revert := clipboardAll | |
clipboard = %this_label%("text") | |
send ^{v}{left}+{left 6} | |
clipboard := clipboard_revert | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
quick msg
message commands that are quick to type and easy to switch between
msg_box()
msg_tray()
msg_tool()
msg_splash()
since these were made with quick string debugging in mind, only the text parameter is used and the unimportant things like title text and timeout options are left out or set to defaults.
- to check for trailing spaces or linefeeds add
q
ora
to the second parameter.- add a space, tab or linefeed to show those invisible characters as text.
- add
c
to have the message contents added to the clipboard.- hover the cursor over a tooltip or splash window to stop it from closing.
- switch between message types by changing the name after msg_ to
box
,tray
,tool
orsplash
.- the text parameter can be left blank if you just want test whether part of your code is being run or not
Â
options:
1
2
3
msg_box(string, "ac")
msg_box(string, 31)
msg_box(string, "`r`n")
Â
sublime snippets: ➜ download
when the snippets are used, the quotes and text will be selected first.
press the
tab
key to move the selection inside the quotesthe snippets can be typed quickly with just a few keystrokes:
mb
,mtr
,mt
,ms
Â