You're looking for A_ThisHotkey.
Example usage:
a::
b::
c::
MsgBox, You pressed %A_ThisHotkey%.
return
Question
The background is I'm writing a small script to pop up an application window with hotkeys, both application and hotkey can be customized with an ini
file. I've completed it with AutoItv3 and it works fine for me. Now I'm considering re-implementing it with AHK_L(preferred) or Basic, yet I can't find the alternative way of doing dynamically binding hotkeys
in AHK while in AutoIt @HotKeyPresssed
is helpful as discussed here.
My code in AutoItv3 is basically like this:
For 1 to $NumberOfKeys
$Key = ReadOneKeyFromIniFile()
HotKeySet($Key,"_Main")
Next
Func _Main()
$AppKeyBind = @HotKeyPressed
$Parameters = ReadParametersFromIniFileAccordingToKey($AppKeyBind)
PopUpWindowWithHotKey($Parameters)
EndFunc
@HotKeyPressed
used here is mainly aiming to break the limitation that HotKeySet()
can't bind $Key
to function _Main
with parameters.
Solution
You're looking for A_ThisHotkey.
Example usage:
a::
b::
c::
MsgBox, You pressed %A_ThisHotkey%.
return