maetthew Posted January 2, 2017 Share Posted January 2, 2017 Hello, I'm new to AutoIt but loving it so far. I have a script that is running, and while running I'm looking for if any of the following keys is pressed to stop run: ESC, Tab or Enter. The script looks something like this: #include <Misc.au3> Const $user32 = DllOpen("user32.dll") Local $StopKeys = ["0D", "09", "1B"] ; Keys to look for and exit: Enter, TAB & ESC keys While True For $key in $StopKeys ; Iterate through each key in $StopKeys If _IsPressed($key, $user32) Then ; Check if any of them are pressed While _IsPressed($key, $user32) ; Wait for release Sleep(50) WEnd Exit ; Exit EndIf Next WEnd I was just wondering if this is the best way to accomplish this. Is there another approach to this that I'm missing? Thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted January 2, 2017 Developers Share Posted January 2, 2017 I probably would use an event based approach with HotKeySet(). Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Subz Posted January 2, 2017 Share Posted January 2, 2017 Wrote something similar last week which may help. 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