Jump to content

Check HotKey Registration


Go to solution Solved by Andreik,

Recommended Posts

Is there a way to check if a hotkey is currently registered within AutoIt?

Looking for a way to Pause a hotkey so I can bypass AutoIt and temporarily utilize the key until I decide to resume. Something like:

HotKeySet("{PAUSE}", "Pause")

Func Pause()
    If HotKeyRegistered("{F1}") Then
        HotKeySet("{F1}")
    Else
        HotKeySet("{F1}", "Toggle")
    EndIf
EndFunc

Yes I am being lazy, but also curious because I did not find anything relatable. I know I could probably set a variable indicating it's on or off.

Edited by kjpolker
Link to comment
Share on other sites

  • Solution
HotKeySet('a', 'Test')

ConsoleWrite(IsHotkeyRegistered(0x41) & @CRLF)  ; vKey for letter A
ConsoleWrite(IsHotkeyRegistered(0x42) & @CRLF)  ; vKey for letter B

Func IsHotkeyRegistered($vkCode)
    Local $aCall = DllCall('user32.dll', 'bool', 'RegisterHotKey', 'hwnd', Null, 'int', 1, 'uint', 0x4000, 'uint', $vkCode)
    If $aCall[0] = 0 Then
        Return True
    Else
        DllCall('user32.dll', 'bool', 'UnregisterHotKey', 'hwnd', Null, 'int', 1)
        Return False
    EndIf
EndFunc

Func Test()
    ConsoleWrite('Yayyy!' & @CRLF)
EndFunc

 

Edited by Andreik
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...