hiimjoey11 Posted January 21, 2015 Posted January 21, 2015 So currently I have this where it will pop up a message box when i press ESC in that particular window. What it also does it still send the ESC key command. I am trying to make it NOT send ESC if that particular window is active. Here is what i tried so far, but didn't seem to work. Do I need to do a keyboard hook or something? #include <Misc.au3> While 1 If _IsPressed("1B") AND WinActive("MyWindow") Then ;Disable ESC key here MsgBox(0, "", "Esc pressed") EndIf WEnd
Solution MikahS Posted January 21, 2015 Solution Posted January 21, 2015 (edited) Something like this: Local $hotKey = 0 While 1 If WinActive("MyWindow") Then $hotKey = HotKeySet("{ESC}", "DoNothing") Else If $hotKey = 0 Then ContinueLoop Else $hotKey = HotKeySet("{ESC}") EndIf EndIf WEnd Func DoNothing() ;0/0 EndFunc Does that help? Edited January 21, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
hiimjoey11 Posted January 21, 2015 Author Posted January 21, 2015 (edited) Something like this: While 1 If WinActive("MyWindow") Then HotKeySet("{ESC}", "DoNothing") Else HotKeySet("{ESC}") EndIf WEnd Func DoNothing() ;0/0 EndFunc Does that help? Ah! PERFECT. Thank you very much! Edited January 21, 2015 by hiimjoey11
MikahS Posted January 21, 2015 Posted January 21, 2015 Ah! PERFECT. Thank you very much! My pleasure. P.S. The only reason I added the extra If statement was so that you are not sitting their calling HotKeySet("{ESC}") every time you loop through, just because that certain window is not active. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
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