cappy2112 Posted January 17, 2006 Share Posted January 17, 2006 In a For loop, I'm controlling another app. I've come across a bug in my AutoIt app, which closed the other program, but left my AutoIt program running- broken. That is, clicking on the X border Icon wouldn't close my AutoIt progam. I think I know why- several functions down, in my for loop, I do this, so my program waits for the target app windows to be active Func WindowMakeActive($WindowTitleText) Local $Ret If Not WinActive($WindowTitleText, "") Then WinActivate($WindowTitleText, "") $Ret= WinWaitActive($WindowTitleText, "") if( Not $Ret) Then WriteErrorLog("WinWaitActive returned " & String($Ret) & "for this window -> " & $WindowTitleText) endif return( $Ret ) EndFunc ;==>WindowMakeActive Ok, so I dont have any timeouts now- thats bad. Is there a way to kill a runaway AutoIt app without going to TaskManager? Why doesnt the X border Icon work? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 17, 2006 Moderators Share Posted January 17, 2006 HotKeySet('{Esc}', 'ExitNow') Func ExitNow() Exit EndFunc 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. Link to comment Share on other sites More sharing options...
cappy2112 Posted January 17, 2006 Author Share Posted January 17, 2006 HotKeySet('{Esc}', 'ExitNow') Func ExitNow() Exit EndFunc Is there anything that can be done to make the X icon work? Some users may not think of the ESC key Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 17, 2006 Moderators Share Posted January 17, 2006 If your talking about a GUI then you've run into an issue of being stuck in a 'while loop' in another function that has sleeps in it or like you said, WinWait()... you could put a timer on the WinWait() Or... you can just re-write everything to OnEventMode ... GUISetOnEvent() for everything rather than using case statments. 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. Link to comment Share on other sites More sharing options...
cappy2112 Posted January 17, 2006 Author Share Posted January 17, 2006 If your talking about a GUI then you've run into an issue of being stuck in a 'while loop' in another function that has sleeps in it or like you said, WinWait()... you could put a timer on the WinWait() Or... you can just re-write everything to OnEventMode ... GUISetOnEvent() for everything rather than using case statments.I am using OnEvent modeopt("GUIOnEventMode", 1) Link to comment Share on other sites More sharing options...
seandisanti Posted January 19, 2006 Share Posted January 19, 2006 HotKeySet('{Esc}', 'ExitNow') Func ExitNow() Exit EndFunckind of redundant isn't it? I mean with escape killing the script by default already anyway... GUICloseOnESC When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent. This option toggles this behavior on and off. 1 = Send the $GUI_EVENT_CLOSE message when ESC is pressed (default). 0 = Don't send the $GUI_EVENT_CLOSE message when ESC is pressed.the thing is he doesn't have a function setup to handle the $GUI_EVENT_CLOSE event. add this to your script somewhere before the while loop that keeps the gui up, but after your GUICreate(). GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") and add this function to the bottom of your script. Func CLOSEClicked() Exit EndFunc Link to comment Share on other sites More sharing options...
cappy2112 Posted January 19, 2006 Author Share Posted January 19, 2006 kind of redundant isn't it? I mean with escape killing the script by default already anyway... the thing is he doesn't have a function setup to handle the $GUI_EVENT_CLOSE event. add this to your script somewhere before the while loop that keeps the gui up, but after your GUICreate(). GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") and add this function to the bottom of your script. Func CLOSEClicked() Exit EndFunc Thanks- this makes sense now. I didn't know how to setup an event handler for that X icon, since I didn't create it. I've been spoiled by Visual Basic. Link to comment Share on other sites More sharing options...
seandisanti Posted January 19, 2006 Share Posted January 19, 2006 Thanks- this makes sense now.I didn't know how to setup an event handler for that X icon, since I didn't create it.I've been spoiled by Visual Basic.no problem, glad to help. Link to comment Share on other sites More sharing options...
cappy2112 Posted January 20, 2006 Author Share Posted January 20, 2006 (edited) kind of redundant isn't it? I mean with escape killing the script by default already anyway... the thing is he doesn't have a function setup to handle the $GUI_EVENT_CLOSE event. add this to your script somewhere before the while loop that keeps the gui up, but after your GUICreate(). GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") and add this function to the bottom of your script. Func CLOSEClicked() Exit EndFunc I've just checked my program, and I already did have the line above in it, after the gui was created, and before the while loop was entered. Now I'm really confused :-) Edited January 20, 2006 by cappy2112 Link to comment Share on other sites More sharing options...
seandisanti Posted January 20, 2006 Share Posted January 20, 2006 I've just checked my program, and I already did have the line above in it, after the gui was created, and before the while loop was entered.Now I'm really confused :-)and did you have the CLOSEClicked function also? i would bet not... 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