ianim8 Posted May 11, 2010 Share Posted May 11, 2010 Good afternoon folks, An AutoIt newbie here. I have created a script that runs an application and switches it into full screen mode. Normally, while in full-screen mode, the 'ESC' button exits full-screen mode and return the user to the program interface. Instead, I would like to capture that 'ESC', and quit the application (exiting full-screen first if needed). I cannot seem to accomplish this. I am on Windows 7 by the way, in case that has any bearing on this. I have tried using the following, stripped down to see if I can disable the 'Esc' key by capturing it and doing nothing. However, pressing 'Esc' still results in the program exiting full-screen mode and into the editor. HotKeySet ("{Esc}", "EscPressed") Func EscPressed() EndFunc Any suggestions would be greatly appreciated. Thanks. Glen Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 Why not just do ProcessClose() on the application when the Esc key is pressed? (Put the ProcessClose() inside your EscPressed().) That way, the Esc will be read by the application, putting it in windowed mode, and then your script will close the application. Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 I tried ProcessClose() but the program just exited fullscreen mode, the program did not close. I have since tried replacing HotKeySet("{Esc}"... with HotKeySet("q"... to see if that would work in case the application was overriding the "Esc" key somehow. With "q" set as the hotkey, pressing q did nothing at all. Is there something set in my system perhaps that is getting in the way? Is this perhaps an issue between AutoIt and Windows 7? Glen Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 Is UAC enabled? Are you running your script with #RequireAdmin? Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 Unfortunately I am not familiar with UAC or #RequireAdmin. Should I be using them? Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 I added the #RequiredAdmin tag but nothing changed, tried both HotKeySet("{Esc}"... and HotKeySet("q"... Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 #RequireAdmin should be used in some cases because the action will not be allowed if you aren't an administrator. UAC, or User Account Control, is something that comes with Windows 7 and Windows Vista that notifies you when a program tries to run, and asks if you want to continue running it. It's the user's choice if they want to use it. I personally don't use it. It may be disabled on your computer already. Can you post the script you have with ProcessClose()? Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 I trimmed it down to the bare minimum and still no luck. I did have it working briefly with CTRL+SHIFT+d but even that doesn't work now. Here is the minimal version of my script: HotKeySet("+d", "TestFunc") Run("C:\Program Files (x86)\metaio\Unifeye Design\Unifeye\Unifeye.exe") WinWaitActive("Unifeye Design 2.0") Send("^f") Func TestFunc() MsgBox(0, "TestFunc", "Executed") EndFunc Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 (edited) Try this: #RequireAdmin HotKeySet("+d", "Terminate") Global $Process = "Unifeye.exe" Run("C:\Program Files (x86)\metaio\Unifeye Design\Unifeye\" & $Process) WinWaitActive("Unifeye Design 2.0") Send("^f") While 1 WEnd Func Terminate() If ProcessExists($Process) Then ProcessClose($Process) MsgBox(0, "Terminate", $Process & " terminated.") EndFunc Edited May 11, 2010 by darkjohn20 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 11, 2010 Developers Share Posted May 11, 2010 Your script ends directly after the windows is detected... is that intentional? 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...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 Your script ends directly after the windows is detected... is that intentional?That's a good point. He should have a while loop in there. But maybe he does? He said that was the "bare minimum" of his script. Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 I think I see the problem, my script is completing and exiting before I get a chance to press the "Esc" key, or any key for that matter. Can I tell the script to pause or wait for keyboard input? Glen Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 (edited) Look at my example. It will work (now). Edited May 11, 2010 by darkjohn20 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 11, 2010 Developers Share Posted May 11, 2010 Look at my example. It will work (now).make sure you add a brief sleep in there to avoid the high CPU utilisation. 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...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 make sure you add a brief sleep in there to avoid the high CPU utilisation.I was about to but I'm to lazy to add formatting in the AutoIt forum. You can't just press tab like in Scite . Link to comment Share on other sites More sharing options...
ianim8 Posted May 11, 2010 Author Share Posted May 11, 2010 Below is the script I ended up writing. It appears to work as I need it to. Is there anything that is problematic, bad protocol, or taxing on the CPU? Thanks for the help everybody, I really appreciate it. Glen ; Script Start - Add your code below here $SplashImage = "C:\PROJECTS_WINVOLVE\Scenario\splash-4x3.gif" SplashImageOn("Welcome to the LifePod Zero Gravity Experience", $SplashImage,1280,1024,-1,-1,1) $file = "C:\PROJECTS_WINVOLVE\Scenario\LifePak15.scef" Run("C:\Program Files (x86)\metaio\Unifeye Design\Unifeye\Unifeye.exe " & $file) WinWaitActive("LifePak15 - Unifeye Design 2.0") Send("^f") Sleep(10000) SplashOff() HotKeySet("{esc}", "captureEsc") While 1 Sleep(10000) WEnd Func captureEsc() ProcessClose("Unifeye.exe") Exit EndFunc Link to comment Share on other sites More sharing options...
darkjohn20 Posted May 11, 2010 Share Posted May 11, 2010 You might want a smaller sleep. Sleep(100) would probably work better. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 11, 2010 Developers Share Posted May 11, 2010 (edited) You might want a smaller sleep. Sleep(100) would probably work better.Nah not really important in this case as there is no other tasks in the close-loop so any sleep() will work. @ianim: Your script looks fine when your intent is to force the program to at least run 10 seconds before the Esc works.Jos Edited May 11, 2010 by 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...
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