Sign in to follow this  
Followers 0
hiimjoey11

Disable ESC if certain window is opened

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by hiimjoey11

Share this post


Link to post
Share on other sites

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 ~ getENVvars
My 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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0