TerminalWalrus Posted February 9, 2012 Share Posted February 9, 2012 Super dooper noober trooper I am. Google is my friend, but I'm having trouble finding an answer to a particular question. It's my understanding that there's some issue with regards to Windows 7 and detecting hot keys being pressed while certain programs are in focus. I imagine this is some type of security feature, but it's in my way. Could someone please explain to me what causes this issue and perhaps suggest a few ways to get around it (aside from installing Windows XP)? I'm learning, so it would be much appreciated. Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2012 Share Posted February 9, 2012 Perhaps you ought to post a script snippet that demonstrates your issue. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
TerminalWalrus Posted February 9, 2012 Author Share Posted February 9, 2012 Okay, say for example then... #RequireAdmin #Include "Misc.au3" Hotkeyset("{esc}", "off") ;*********************************************** Off Switch Global $consoleon If PRocessExists("example.exe") Then $consoleon = 1 ElseIf ProcessExists("example2.exe") Then $consoleon = 1 Else $consoleon = 0 EndIf Global $on = 1 If $on = 0 Then Exit ElseIf $consoleon = 0 Then Exit EndIf Func off() $on = 0 EndFunc ;*********************************************** While $on = 1 ; keeps the script running in the background Sleep(50) WEnd The code works fine to stop the script when I press escape. Unless the window corresponding to example.exe is in focus. Then it doesn't capture the hot key when I press it. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 9, 2012 Share Posted February 9, 2012 Other than commenting out the #RequireAdmin line from your script above, this worked for me using Notepad without a problem. Running this on Windows 7 x64. I had to get rid of the RequireAdmin line because it wouldn't see the Process for Notepad unless I did that. Maybe the program you're having problems with uses Escape as it's own hotkey. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
TerminalWalrus Posted February 10, 2012 Author Share Posted February 10, 2012 Thank you for taking the time, Brew. For anyone reading this with an identical problem in the future, the correct question I should have asked is... What alternative methods exist for setting hotkeys? Therein lay the solution. Hotkeyset works fine for most things, but not everything. Link to comment Share on other sites More sharing options...
Xandy Posted February 10, 2012 Share Posted February 10, 2012 (edited) Could these tools help you? _ispressed() and or winactive() #include <Misc.au3>; header file includes _ispressed() if winactive("window title") then if _ispressed("1B") then $on= 0 endif; end if your hotkey pressed endif;end if your window has focus If you don't care about the window that has focus when ESCAPE is pressed just remove the if winactive and endif. _ispressed will work but the keypress will also be sent to the window with focus. Edited February 10, 2012 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) 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