Jump to content

Click button to start script, click same button to stop

Recommended Posts

How would I go about making this script stop by clicking the same button that activated it?

I figured i needed multithreading, so Iv been trying to use this here:

But I'm not getting too far.


I guess I don't understand how to use the multithreading maybe, or maybe I'm just doing it wrong.

Can someone please help me out?


Edited by houseonfire
Link to post
Share on other sites

You don't need or want multi-threading.

There are lots of ways to do this, some are explained in the Interrupting a running function-tutorial in the wiki, so I suggest you start there.

Link to post
Share on other sites

Another way to do this is like this, although I'd suggest going thru that tutorial as well.

#include <GuiConstantsEx.au3>

Opt("MustDeclareVars", 1)

Local $GUI, $Button

$GUI = GUICreate("one button - two things")
$Button = GUICtrlCreateButton(" Start ", -1, -1)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $Button

Func DoSomething()
    If ControlGetText("one button - two things", "", $Button) = " Start " Then
        ControlSetText("one button - two things", "", $Button, " Stop ")
        MsgBox(0, "", "The script has started doing something")
        ControlSetText("one button - two things", "", $Button, " Start ")
        MsgBox(0, "", "The script has stopped doing something")

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...