imkrut Posted April 5, 2013 Share Posted April 5, 2013 Hey guys, first of all, i ask patience, since I'm super dumb when it comes to scripts, codes, etc. I also been trying stuff on and off, copying scripts, reading help and whatnot, but i sort of hit a wall, and despite trying new stuff i can't quite get it to work. I've used the search function, read numerous posts, and went through the relevant sections on the wiki, but i can't quite make it do what i want it to. Basically, i want this program to run fullscreen, and load a certain file (which i already acomplished by copying scripts and fiddling around). I also want it to close when i press the ESC key, which is also working at the moment. HOWEVER, the script keeps running after the program closes, and upon pressing ESC it closes other programs, i want to correct that. So basically, after that particular program closes, the script should stop, im sure a more correct way of doing it, would be to make the script only work while that particular program is running, but i have no idea how to go about doing that. Also there might be unnecessary lines in there, so if someone is kind enough to correct it and help me, i would much appreciate it. Thanks a bunch. $windows = "DeSmuME 0.9.9 svn4565 x86-JIT" Run ( "C:\Program Files\Steam\SteamApps\common\Emulators\Desmume\DeSmuME.exe castle.nds") WinWait ( $windows ) WinActivate ( $windows ) WinWaitActive ( $windows ) Send("!{ENTER}") HotKeySet("{Esc}", "CloseWindow") While 1 sleep(100) Wend Func CloseWindow() ; ... can do stuff here HotKeySet("{Esc}");unregister hotkey If WinActive("Microsoft Excel") Then Send("{Esc}") Else Send("!{F4}") EndIf HotKeySet("{Esc}", "CloseWindow");re-register EndFunc Link to comment Share on other sites More sharing options...
FireFox Posted April 5, 2013 Share Posted April 5, 2013 (edited) Hi, Welcome to the autoit forum If you want to close the script you have two possibilities : 1. Exit the main loop with the ExitLoop statement. 2. Exit the script with the Exit statement. Local Const $sWndTitle = "DeSmuME 0.9.9 svn4565 x86-JIT" Run("C:\Program Files\Steam\SteamApps\common\Emulators\Desmume\DeSmuME.exe castle.nds") WinWait($sWndTitle) WinActivate($sWndTitle) WinWaitActive($sWndTitle) Send("!{ENTER}") HotKeySet("{Esc}", "CloseWindow") While 1 Sleep(100) WEnd Func CloseWindow() ; ... can do stuff here If WinActive("Microsoft Excel") = 1 Then Send("{Esc}") Else Send("!{F4}") EndIf Exit EndFunc ;==>CloseWindow Note that in your script the hotkey won't work until the window is active. Br, FireFox. Edited April 5, 2013 by FireFox Link to comment Share on other sites More sharing options...
imkrut Posted April 5, 2013 Author Share Posted April 5, 2013 Thank you for the warm welcome, and insanely fast response. Regarding the fix, it worked perfectly sir! Thanks again for the help. Now this is just me being greedy trying to understand the script better, but is there a way to limit the "close window" to a specific program? right now it just closes whatever is active/focused. Thanks again. Link to comment Share on other sites More sharing options...
FireFox Posted April 5, 2013 Share Posted April 5, 2013 (edited) Use the WinClose function Like this : Func CloseWindow() ; ... can do stuff here WinClose("Microsoft Excel") Exit EndFunc ;==>CloseWindow Br, FireFox. Edited April 5, 2013 by FireFox Link to comment Share on other sites More sharing options...
imkrut Posted April 5, 2013 Author Share Posted April 5, 2013 Awesome, all working like i wanted. Thank you so much sir. Link to comment Share on other sites More sharing options...
FireFox Posted April 5, 2013 Share Posted April 5, 2013 You're welcome 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