zeenmakr Posted July 16, 2020 Share Posted July 16, 2020 objective: need to use key pressed in HotKeySet() as it if condition isn't met. example bellow fails because it invokes in endless loop HotKeySet('{RIGHT}', 'test') Func test() If WinActive('[CLASS:MSPaintApp]') Then MsgBox(0, 'Hotkey Pressed', 'RightArrow') Else Send('{RIGHT}') EndIf EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted July 16, 2020 Share Posted July 16, 2020 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 zeenmakr 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
zeenmakr Posted July 16, 2020 Author Share Posted July 16, 2020 (edited) 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 July 16, 2020 by zeenmakr Link to comment Share on other sites More sharing options...
Nine Posted July 16, 2020 Share Posted July 16, 2020 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now