Skip to content

Instantly share code, notes, and snippets.

@jasondavis
Forked from db93n2/msg.ahk
Created February 3, 2018 23:52
Show Gist options
  • Select an option

  • Save jasondavis/4621bc7cb19a5419934ccf5a962bb540 to your computer and use it in GitHub Desktop.

Select an option

Save jasondavis/4621bc7cb19a5419934ccf5a962bb540 to your computer and use it in GitHub Desktop.
πŸ’¬ (autohotkey) - message commands that are quick to type and easy to switch between
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
*/
::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