Sign in to follow this  
Followers 0
Cherubim

Close GUI while "Sleeping"

4 posts in this topic

#1 ·  Posted (edited)

I have the following problem:

The GUI isnt able to close while Autoit is executing sleep.

Is there a way around this, cause my script uses lots of Sleep funtions?

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 309, 180,(@DesktopWidth-309)/2, (@DesktopHeight-168)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Checkbox_1 = GuiCtrlCreateCheckbox("test", 10, 20, 

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        Sleep(10000)
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

Just an example what i meant ;)

Edited by Cherubim

Share this post


Link to post
Share on other sites



You could try using a HotKey, and use an exit option.

HotKeySet("{ESC}", "Terminate")

Func Terminate()

Exit 0

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.

Share this post


Link to post
Share on other sites

You have to use the onEvent mode not the Loop one. ;)

Share this post


Link to post
Share on other sites

Couldn't you just lower the sleep delay to say, 100, so it checks more often and doesn't spend so much time in the sleep mode?

I do agree that OnEvent mode is a better option, but if he wants to stay in GetMsg mode, that should do it.

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