Sign in to follow this  
Followers 0
phatzilla

How to stop a function with a GUI button

4 posts in this topic

So heres the story, i have a gui button "start", when i press it will start a rather long winded function that runs on a loop (If i were to wait for it to finish, would take ~5 minutes or so). However, i want a "stop" button wherein if i push it, it will stop the function at any time.

Here's the relevant code

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
;############################################## Clicked on Play Increase Button #####################################################################
            Case $msg = $Go
    guisetfont(9,4000,0)
    GUICtrlCreateLabel(guictrlread($increase), 260, 130, 300, 50)
    GUICtrlCreateLabel("# increased : ", 157, 170, 300, 15)
    $increaser = guictrlcreatelabel("0",260,170,100,15)
    increaser() ; run our increaser function
 
;############################################## Clicked on Stop Play increaser #####################################################################
   case $msg = $stop
  
Dont iknow what to put here!
 
        EndSelect
    WEnd

So after i click start, the "increaser()" function begins, however i want to be able to stop that function even if its half way through, but it seems as if it only waits for the function to finish before any buttons become "active" on the gui...

any help

Share this post


Link to post
Share on other sites



http://www.autoitscript.com/wiki/Interrupting_a_running_function

Share this post


Link to post
Share on other sites

I'm a newbie to this stuff still but I think you just loop the function until it's done or you hit the button and end function.

Share this post


Link to post
Share on other sites

Replace "Dont iknow what to put here!" by ExitLoop


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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