原來AutoHotkey自從1.1.28版開始已經提供了稱為Function Hotstrings的功能了,簡單理解就是能在熱字串裡寫腳本程式碼了。
另外,也可以使用Hotstring函數動態控制熱字串。
範例
#SingleInstance Force
; This example also demonstrates one way to implement case conformity in a script.
:C:BTW:: ; Typed in all-caps.
:C:Btw:: ; Typed with only the first letter upper-case.
: :btw:: ; Typed in any other combination.
btw() {
hs := A_ThisHotkey ; For convenience and in case we're interrupted.
if (hs == `":C:BTW")
Send BY THE WAY
else if (hs == ":C:Btw")
Send By the way
else
Send by the way
}
::tst::
SendInput #e
return
::aa:: Hotstring(": :btw", "new BTW string")
::bb:: btw()
::cc::
btw()
return
::dd::
try
Hotstring("::btw", " bb tt ww")
catch
MsgBox The hotstring does not exist or it has no variant for the current IfWin criteria.
return💡 相關鏈接
✅ Function Hotstrings: https://www.autohotkey.com/docs/Hotstrings.htm#Function
✅ Hotstring: https://www.autohotkey.com/docs/commands/Hotstring.htm
教學影片
##
