Sign in to follow this  
Followers 0
KilRoy

Block Esc Only For Current App

8 posts in this topic

I am in the middle of a program and I want to block exiting the app with the ESC key. I have put a BlockInput function to block it, but it blocks it globally as long as the app is running. This could be a problem if the user is running another application and needs the ESC key. Is there any way to block the key only for one application and not globally? Or am I looking at it wrong and need to go another route? I've searched the forum, but it seems nobody has tried, or needed, to do this before. Is it possible?

Thanks for all your help.

KilRoy

Share this post


Link to post
Share on other sites



I am in the middle of a program and I want to block exiting the app with the ESC key. I have put a BlockInput function to block it, but it blocks it globally as long as the app is running. This could be a problem if the user is running another application and needs the ESC key. Is there any way to block the key only for one application and not globally? Or am I looking at it wrong and need to go another route? I've searched the forum, but it seems nobody has tried, or needed, to do this before. Is it possible?

Thanks for all your help.

KilRoy

Why not just disable the X on your GUI (If you have one) and any buttons that normally would make your application exit? I say this, because no matter what hotkey you or BlockInput() you use, Ctrl+Alt+Delete = Task Manager and you app can/would be killed there anyway.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I want to be able to exit normally, but not with the ESC key. "Normal" exit would be the X on the GUI, File>Exit, or Exit button. Sorry for not being clear.

I'm a systems guy and I hear users whine about everything, so I'm trying to get ahead of them with this one!

Thanks.

KilRoy

Share this post


Link to post
Share on other sites

I want to be able to exit normally, but not with the ESC key. "Normal" exit would be the X on the GUI, File>Exit, or Exit button. Sorry for not being clear.

I'm a systems guy and I hear users whine about everything, so I'm trying to get ahead of them with this one!

Thanks.

KilRoy

Ahh, you could try to steal the ESC key like:
HotKeySet('{ESC}', '_DoNothing')

While 1
;Your script
    Sleep(100000)
WEnd

Func _DoNothing()
EndFunc
See if that works..

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

gafrost: That did it! Thanks for opening my eyes!

Smoke: I did the hotkey set and it made the ESC not work anywhere while the program was running. I seems the Opt is what I'm looking for.

As I said before, this forum is a great learning tool! Thanks for all the help and putting up with dummo questions from people like me!

KilRoy

Share this post


Link to post
Share on other sites

Lmao... I was just testing what I did when I re-read your post and realized it wasn't going to work. Then I decided to look at the Opt's in the help file, and found what Gary just posted... ahh well, that's what I get for staying up all night, glad he was here to help ya out!


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

gafrost: That did it! Thanks for opening my eyes!

Smoke: I did the hotkey set and it made the ESC not work anywhere while the program was running. I seems the Opt is what I'm looking for.

As I said before, this forum is a great learning tool! Thanks for all the help and putting up with dummo questions from people like me!

KilRoy

Here's another option to steal it from any window.

* Untested

While 1
  If WinActive("Window Title") Then
    Hotkeyset("{ESC}", "Nothing")
  Else
    Hotkeyset("{ESC}")
  EndIf
  Sleep(100)
Wend

[edit] Added sleep

Edited by Manadar

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