This is a library that adds a dynamic hotstring feature for Autohotkey.
Arguments:
trigger- A string/regex that triggers the hotstrings.label- A string to replace the trigger/label to goto/ name of function to call when the hotstring is triggered. If it's a label, the variable$will contain either the phrase that triggered the hotstring or a MatchObject (Ifmode == 3) If it's a function and the function takes atleast 1 parameter, the first parameter will be the trigger string, or the Match Object.mode- A number between 1 & 3. 1 creates a case insenstive hotstring, 2 creates a case sensitive hotstring, 3 creates a regex hotstring. Defaults to1.clearTrigger- Wheather or not to clear the trigger. Defaults totrue.cond- A name of a function that is to be called everytime the hotstring is triggered. If this function returns a false value or if it returns nothing, the hotstring is not triggered.
##Examples:
#IncludeHotstring.ahk
Hotstring("btw", "by the way") ; Case insensitive.; btw -> by the way; BTW -> by the way; BtW -> by the way; bTw -> by the way.; annd so on.
Hotstring("ahk", "autohotkey", 2) ; Case sensitive. ; only ahk will trigger it. AHK, aHk, or AhK won't trigger it#IncludeHotstring.ahk
Hotstring("toLabel", "label")
returnlabel:
; $ == "toLabel"return#IncludeHotstring.ahk
Hotstring("(\d+)\/(\d+)%", "percent",3)
returnpercent:
; now $ is a match object.sendInput, % Round(($.Value(1)/$.Value(2))*100)
; 2/2% -> 100; 70/100 -> 70%return#IncludeHotstring.ahk
Hotstring("i)((d|w)on)(t)", "$1'$3",3) ;DONT -> DON'T;dont -> don't;dOnt -> dOn't;WONT -> WON'T;and so on.
Hotstring("i)colou?rs","$0 $0 everywhere!", 3) ; Regex, Case insensitive; colors -> 'colors colors everywhere!'; colours -> 'colours colours everywhere!'#IncludeHotstring.ahk
Hotstring("trigger", "replace") ;Case Insensitivereturnreplace($){
; $ == 'trigger'Msgbox %$% was entered!
}#IncludeHotstring.ahk
Hotstring("i)regex_(trigger)", "replace",3) ;Regexreturnreplace($){
;$ is a match ObjectMsgbox % $.Value(0) . " was entered."Msgbox % $.Value(1) . " == 'trigger'"
}#IncludeHotstring.ahk
Hotstring("trigger", "replace")
Sleep,4000
Hotstring("trigger","") ; Removes the hotstring