Jump to content

Recommended Posts

Posted (edited)

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.

Thanks

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?

Thanks

Edited by houseonfire
Posted

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)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            DoSomething()
    EndSwitch
    Sleep(10)
WEnd

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")
    Else
        ControlSetText("one button - two things", "", $Button, " Start ")
        MsgBox(0, "", "The script has stopped doing something")
    EndIf
EndFunc

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

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
×
×
  • Create New...