d0n Posted September 3, 2009 Share Posted September 3, 2009 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 More sharing options...
99ojo Posted September 4, 2009 Share Posted September 4, 2009 (edited) 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 September 4, 2009 by 99ojo Link to comment Share on other sites More sharing options...
d0n Posted September 6, 2009 Author Share Posted September 6, 2009 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 More sharing options...
rvn Posted September 7, 2009 Share Posted September 7, 2009 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 More sharing options...
Mison Posted September 7, 2009 Share Posted September 7, 2009 simplest and easiest way to pause a script... click running script's icon on the system tray.. hehehehe Hi ;) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now