What's the alternative command in AHK_L or AHK Basic as @HotKeyPressed in AutoItv3?

StackOverflow https://stackoverflow.com/questions/23486086

  •  16-07-2023
  •  | 
  •  

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.

Était-ce utile?

La solution

You're looking for A_ThisHotkey.
Example usage:

a::
b::
c::
    MsgBox, You pressed %A_ThisHotkey%.
return
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top