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

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

  •  16-07-2023
  •  | 
  •  

문제

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.

도움이 되었습니까?

해결책

You're looking for A_ThisHotkey.
Example usage:

a::
b::
c::
    MsgBox, You pressed %A_ThisHotkey%.
return
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top