Jump to content

Debugging: What to do when the X border Icon doesn't close your app


cappy2112
 Share

Recommended Posts

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

  • Moderators

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

  • Moderators

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

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 mode

opt("GUIOnEventMode", 1)

Link to comment
Share on other sites

HotKeySet('{Esc}', 'ExitNow')

Func ExitNow()
    Exit
EndFunc
kind 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

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

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 by cappy2112
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...