Sign in to follow this  
Followers 0
cappy2112

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

10 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Func ExitNow()
    Exit
EndFunc


[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.


[center]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.[/center]

Share this post


Link to post
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)

Share this post


Link to post
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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by cappy2112

Share this post


Link to post
Share on other sites

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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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
Sign in to follow this  
Followers 0