Jump to content

Escape key assigned in HotKeySet()


Recommended Posts

I believe the typical way to handle this is to "unbind" the hotkey at the start of your function and then enable it again at the bottom --

HotKeySet('{RIGHT}', 'test')

Func test()
      HotKeySet('{RIGHT}')
      If WinActive('[CLASS:MSPaintApp]') Then
        MsgBox(0, 'Hotkey Pressed', 'RightArrow')
      Else
        Send('{RIGHT}')
      EndIf
      HotKeySet('{RIGHT}', 'test')
EndFunc

 

Link to comment
Share on other sites

1 hour ago, Danp2 said:

I believe the typical way to handle this is to "unbind" the hotkey at the start of your function and then enable it again at the bottom

it obvious from the document but didn't know what it meant. it still a mystery to me, so how does it work?

so, initial {Esc} key pressed call captureEsc(), then  unregister/unbind {Esc} key event then able to send {Esc} as 'raw' key, and why set HotKeySet("{Esc}", "captureEsc") inside the function?

; capture and pass along a keypress
HotKeySet("{Esc}", "captureEsc")
Func captureEsc()
    ; ... can do stuff here
    HotKeySet("{Esc}")
    Send("{Esc}")
    HotKeySet("{Esc}", "captureEsc")
EndFunc

 

Edited by zeenmakr
Link to comment
Share on other sites

Yes, but remember that there is quite a large elapse time between unregistering a hotkey and reregistering the key.  If you type real fast, you will find that this is not a good approach to take.

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...