Home

Awesome

Hotstring

This is a library that adds a dynamic hotstring feature for Autohotkey.

Arguments:

##Examples:

#Include Hotstring.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
#Include Hotstring.ahk

Hotstring("toLabel", "label")
return

label:
; $ == "toLabel"
return

#Include Hotstring.ahk
Hotstring("(\d+)\/(\d+)%", "percent",3)
return

percent:
; now $ is a match object.
sendInput, % Round(($.Value(1)/$.Value(2))*100)
; 2/2% -> 100
; 70/100 -> 70%
return
#Include Hotstring.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!'

#Include Hotstring.ahk

Hotstring("trigger", "replace") ;Case Insensitive
return

replace($){
	; $ == 'trigger'
	Msgbox %$% was entered!
}
#Include Hotstring.ahk

Hotstring("i)regex_(trigger)", "replace",3) ;Regex
return

replace($){
	;$ is a match Object
	Msgbox % $.Value(0) . " was entered."
	Msgbox % $.Value(1) . " == 'trigger'"
}
#Include Hotstring.ahk

Hotstring("trigger", "replace")
Sleep,4000
Hotstring("trigger","") ; Removes the hotstring