Sign in to follow this  
Followers 0
Stealth111

Need Help getting gui to exit on close or esc

3 posts in this topic

I am having the darnedest time trying to figure out why my script will not exit when I hit the esc button or press the close on the top right corner of the gui.. I have to press esc over and over or press close over and over for it to finally close. I will paste the relevant areas of the script. I have AutoItSetOption("GUICloseOnESC",1) as the very first line of the script, then

[/code]
for $i = 1 to $FileCount
           
            $seet = FileReadLine($list)
            if @error= -1 Then ExitLoop
            ping($seet,50)
            
            if @error <> 0 Then
                _ArrayAdd($PingSuccess,$seet)
            Else
                _ArrayAdd($PingFail,$seet)
            EndIf
            GUICtrlSetData ($progressbar1,($i/$FileCount)*100)   
    $exitmsg = GUIGetMsg()
    If $exitmsg = $GUI_EVENT_CLOSE Then Exit            
        Next
        _GUICtrlListClear($List2)
NOW the exit DOES work in this function just perfectly, using esc or just closing the gui, but...

the part below DOES NOT WORK!!
for $z = 1 to $Sleep $restmsg = GUIGetMsg() If $restmsg = $GUI_EVENT_CLOSE Then Exit sleep(1000) If $restmsg = $GUI_EVENT_CLOSE Then Exit $restmsg = GUIGetMsg() If $restmsg = $GUI_EVENT_CLOSE Then Exit next
The above does NOT work.. basically I have set the variable $sleep earlier in the program, and I need the program to sleep for whatever time was set in the variable BEFORE it runs the previous function again, but the problem is that it will not allow me to exit the program while it is sleeping.. I did have a regular sleep($sleep) type of command but I I knew that exiting the program would not work while it was sleeping, short of closing it via icon in the tray, which I don't want to rely on.. so as you can see I tried to open up the sleep function giving the program a place to check to see if esc was pressed or if an attempt was made to close the program.. but it doesn't work for $hit.. it is sporadic at best, sometimes it will close, sometimes it wont close even if you are clicking the hell out of the close button, or even repeatedly hitting the esc button.. ANY ideas on how I can re script the delay to include a working exit while it is waiting??

Share this post


Link to post
Share on other sites



Anyone??

Share this post


Link to post
Share on other sites

Hmm... are you using GUIOnEventMode or normal messageloop mode? Can you achieve what you want without the sleep commands using onevent? I wish someone else would comment on this but I don't think you can ever do two things at once, so sleeping and trying to exit simply won't work. If you can't remove your sleep, maybe you can break it down into several sleep commands? For instance if you need it to sleep for 1000 can it be 3 sleeps for 333? (Note as I reread your post it seems as though you may have done this already.) Other then that it seems like you are a little stuck unless you can remove those sleep commands


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

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