Jump to content

starting and stopping script


d0n
 Share

Recommended Posts

What i want to do is once i click start it will keep looping my script, but i want to be able to stop it or exit the script when i click a button

Is there a way to do it?

So far i have this, which didn't work, its just stuck in the loop

Gui()

Func Gui()
    GUICtrlSetOnEvent($Tab1_Button1, "Start")
    GUICtrlSetOnEvent($Tab1_Button2, "Stop")
    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc
;====================
;=====Stop
;====================
Func Stop()
    Exit
EndFunc

;====================
;=====Start
;====================
Func Move()
    While 1
        Msgbox("","","")
    WEnd
EndFunc
Link to comment
Share on other sites

What i want to do is once i click start it will keep looping my script, but i want to be able to stop it or exit the script when i click a button

Is there a way to do it?

So far i have this, which didn't work, its just stuck in the loop

Gui()

Func Gui()
    GUICtrlSetOnEvent($Tab1_Button1, "Start")
    GUICtrlSetOnEvent($Tab1_Button2, "Stop")
    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc
;====================
;=====Stop
;====================
Func Stop()
    Exit
EndFunc

;====================
;=====Start
;====================
Func Move()
    While 1
        Msgbox("","","")
    WEnd
EndFunc

Hi,

you have set

Opt("GUIOnEventMode", 1) at the beginning of your script? (see help GUICtrlSetOnEvent)

For better help you should show more code.........

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Yea i have something like this

Opt("GUIOnEventMode", 1)
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Test", 315, 260)
$Tab1_Button1 = GUICtrlCreateButton("Start", 100, 180, 80, 25)
$Tab1_Button2 = GUICtrlCreateButton("Stop", 100, 210, 80, 25)
GUISetState(@SW_SHOW)

Gui()

Func Gui()
    GUICtrlSetOnEvent($Tab1_Button1, "Move")
    GUICtrlSetOnEvent($Tab1_Button2, "Stop")
    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc

;====================
;=====Stop
;====================
Func Stop()
    Exit
EndFunc

;====================
;=====Start
;====================
Func Move()
    While 1
        Msgbox("","","")
    WEnd
EndFunc
Link to comment
Share on other sites

how bout this script...

#script start here

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.0.0

Author: rvn

Script Function:

manual loop when start

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Global $nMsg, $status

$status = 0

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Manual loop", 184, 41, -1, -1)

$Button1 = GUICtrlCreateButton("Start", 8, 8, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Stop", 96, 8, 75, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

start_()

Case $Button2

stop_()

EndSwitch

If $status = 0 Then

Else

ToolTip ( "Loop ur script here",Random(1,@DesktopWidth),Random(1,@DesktopHeight),"Loop ur script here")

EndIf

WEnd

Func start_()

$status = 1

EndFunc

Func stop_()

$status = 0

EndFunc

#end of script

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...