Zisly Posted March 31, 2008 Share Posted March 31, 2008 Well im trying to do so if i press a button (pause) then the script will pause then if i press "start" it will start again,but it's not working. Can someone help me? If anything else would be wrong you could tell me also , but i guess everything is right exept the pause/start code Thanks expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\omnibook\Skrivbord\CZ.kxf\CZ.kxf $Form2 = GUICreate("Z Clicker 1.1", 346, 282, 293, 161) $Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\ZC.bmp", 0, 0, 345, 281, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("(Not allowed)", 112, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\Start.bmp", 0) $Button2 = GUICtrlCreateButton("(Not allowed)", 232, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\pause.bmp", 0) $Button3 = GUICtrlCreateButton("(Not allowed)", 256, 216, 78, 47, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\exit2.bmp", 0) $Button4 = GUICtrlCreateButton("(Not allowed)", 120, 104, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\5sec.bmp", 0) $Button5 = GUICtrlCreateButton("(Not allowed)", 120, 144, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\10sec.bmp", 0) $Button6 = GUICtrlCreateButton("(Not allowed)", 120, 184, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\15 sec.bmp", 0) $Group1 = GUICtrlCreateGroup("Click Delay", 120, 80, 73, 25, BitOR($BS_CENTER,$BS_FLAT,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlCreateGroup("Click Delay", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) MouseClick("left") sleep(5000) MouseClick("left") WEnd Case $Button2;;;;;;;;;;PAUSAR ("{PAUSE}") Case $Button3;;;;;;OM EXIT DÅ EXIT Exit Case $Button4 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) MouseClick("left") sleep(5000) MouseClick("left") WEnd Case $Button5 While 1 MouseClick("left");;;;10 SEC DELAY CLICK sleep(10000) MouseClick("left") sleep(10000) MouseClick("left") WEnd Case $Button6 While 1 MouseClick("left");;;;15 SEC DELAY CLICK sleep(15000) MouseClick("left") sleep(15000) MouseClick("left") WEnd Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 (edited) Well im trying to do so if i press a button (pause) then the script will pause then if i press "start" it will start again,but it's not working. Can someone help me? If anything else would be wrong you could tell me also , but i guess everything is right exept the pause/start code Thanks expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\omnibook\Skrivbord\CZ.kxf\CZ.kxf $Form2 = GUICreate("Z Clicker 1.1", 346, 282, 293, 161) $Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\ZC.bmp", 0, 0, 345, 281, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("(Not allowed)", 112, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\Start.bmp", 0) $Button2 = GUICtrlCreateButton("(Not allowed)", 232, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\pause.bmp", 0) $Button3 = GUICtrlCreateButton("(Not allowed)", 256, 216, 78, 47, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\exit2.bmp", 0) $Button4 = GUICtrlCreateButton("(Not allowed)", 120, 104, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\5sec.bmp", 0) $Button5 = GUICtrlCreateButton("(Not allowed)", 120, 144, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\10sec.bmp", 0) $Button6 = GUICtrlCreateButton("(Not allowed)", 120, 184, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\15 sec.bmp", 0) $Group1 = GUICtrlCreateGroup("Click Delay", 120, 80, 73, 25, BitOR($BS_CENTER,$BS_FLAT,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlCreateGroup("Click Delay", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) MouseClick("left") sleep(5000) MouseClick("left") WEnd Case $Button2;;;;;;;;;;PAUSAR ("{PAUSE}") Case $Button3;;;;;;OM EXIT DÅ EXIT Exit Case $Button4 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) MouseClick("left") sleep(5000) MouseClick("left") WEnd Case $Button5 While 1 MouseClick("left");;;;10 SEC DELAY CLICK sleep(10000) MouseClick("left") sleep(10000) MouseClick("left") WEnd Case $Button6 While 1 MouseClick("left");;;;15 SEC DELAY CLICK sleep(15000) MouseClick("left") sleep(15000) MouseClick("left") WEnd Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd OIC... the pause code you used... Pause... is a toggle and it neatly pauses execution of your application.... heh... I'd replace that with a loop that has as it's exit condition, selecting the restart button... Edited March 31, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
TomZ Posted March 31, 2008 Share Posted March 31, 2008 Example from the helpfile: ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFunc Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 Example from the helpfile: ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage");Shift-Alt-d ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFunc Or... what he said Everseeker Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 But i want it to pause when i CLICK ON A BUTTON in my menu i did, not hotkey. Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 (edited) Case $Button2; PAUSAR $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Pauser"',0,0) WEnd ToolTip("") This is the function you need... use this in place of the function you currently have assigned to pausing..... Edited March 31, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks, i'll test it Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 Case $Button2; PAUSAR $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Pauser"',0,0) WEnd ToolTip("") This is the function you need... use this in place of the function you currently have assigned to pausing.....wait... that will not work... hang on while I work on this... Everseeker Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 (edited) wait... that will not work... hang on while I work on this...Case $Button2; PAUSAR While 1=1 sleep(100) ToolTip('Script is "Pauser"',0,0) $nMsg = GUIGetMsg() If $nMsg=$Button1 then exitloop endif WEnd ToolTip("") Give that a shot... (I am assuming that $Button1 will only evaluate as "True" when the button is pressed... correct?) Edited March 31, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
Developers Jos Posted March 31, 2008 Developers Share Posted March 31, 2008 (edited) Case $Button2; PAUSAR While 1=1 sleep(100) ToolTip('Script is "Pauser"',0,0) If $Button1 then exitloop endif WEnd ToolTip("") Give that a shot... (I am assuming that $Button1 will only evaluate as "True" when the button is pressed... correct?)C'mon folks... this is never ever going to work properly. rule 1: Thow shall not use a Sleep() in a GUI message loop. Best shot would be to use the GUI in event mode. Secondly: Where are you updating $button1 in your proposal ? Edited March 31, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 C'mon folks... this is never ever going to work properly. rule 1: Thow shall not use a Sleep() in a GUI message loop. Best shot would be to use the GUI in event mode.Secondly: Where are you updating $button1 in your proposal ?1. Came from example....2. My bad... I was editing the OP while you were replying...I was not evaluating the correct expression.... Everseeker Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 Case $Button2; PAUSAR $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Pauser"',0,0) WEnd ToolTip("") This is the function you need... use this in place of the function you currently have assigned to pausing.....Doesn't work,well it pauses the script but i can turn it on or click on anything on my menu,not even shut it down with. Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 1. Came from example....2. My bad... I was editing the OP while you were replying...I was not evaluating the correct expression.... $nMsg = GUIGetMsg() If $nMsg=$Button1 then exitloop needs to be inserted into each of your delay loops is you EVER want to be able to get out of them...Soon as you get to that While 1.... you're done Everseeker Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 Like this? Case $Button4 While 1 $nMsg = GUIGetMsg() If $nMsg=$Button1 then exitloop MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) WEnd Link to comment Share on other sites More sharing options...
everseeker Posted March 31, 2008 Share Posted March 31, 2008 $nMsg = GUIGetMsg()If $nMsg=$Button1 then exitloopneeds to be inserted into each of your delay loops is you EVER want to be able to get out of them...Soon as you get to that While 1.... you're doneYour script seems to have several issues.... What exactly are you attempting to do? Everseeker Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 I tried to do what you told me?... Give me an example please. Link to comment Share on other sites More sharing options...
monoceres Posted March 31, 2008 Share Posted March 31, 2008 (edited) Here's the simpliest way of pausing a script with a button (on event mode): #include <GUIConstants.au3> Global $bool=False Opt("GUIOnEventMode",1) GUICreate("Test GUI",200,100) GUICtrlCreateButton("Pause!",10,10) GUICtrlSetOnEvent(-1,"pause") GUISetOnEvent($GUI_EVENT_CLOSE,"close") GUISetState() while 1 while $bool Sleep(100) WEnd Sleep(50) WEnd Func close () Exit EndFunc Func pause () If NOT $bool Then $bool=True ToolTip("Script is paused!") Else $bool=False ToolTip("") EndIf EndFunc Edited March 31, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 I dont get it (in new to autoit) so i cant use that code for my gui menu? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 31, 2008 Developers Share Posted March 31, 2008 Looks like a clear case of running before knowing how to crawl .. Try to take more than 5 seconds to study the posted example and to interpret it. After that you can come back for questions. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Zisly Posted March 31, 2008 Author Share Posted March 31, 2008 (edited) I think i got it now,but now it comes up with an error "'EndIf' statenent with no matching "If" statement",but there is a If on the right place :S Code.. expandcollapse popup#include <GUIConstants.au3> Global $bool=False Opt("GUIOnEventMode",1) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\omnibook\Skrivbord\CZ.kxf\CZ.kxf $Form2 = GUICreate("Z Clicker 1.1", 346, 282, 293, 161) $Pic1 = GUICtrlCreatePic("C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\ZC.bmp", 0, 0, 345, 281, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("(Not allowed)", 112, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\Start.bmp", 0) $Button2 = GUICtrlCreateButton("(Not allowed)", 232, 16, 110, 40, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\pause.bmp", 0) $Button3 = GUICtrlCreateButton("(Not allowed)", 256, 216, 78, 47, $BS_BITMAP) GUICtrlSetOnEvent(-1,"pause") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUISetOnEvent($GUI_EVENT_CLOSE,"close") GUISetState() while 1 while $bool Sleep(100) WEnd Sleep(50) WEnd Func close () Exit EndFunc Func pause () If NOT $bool Then $bool=True ToolTip("Script is paused!") Else $bool=False ToolTip("") EndIf EndFunc GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\exit2.bmp", 0) $Button4 = GUICtrlCreateButton("(Not allowed)", 120, 104, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\5sec.bmp", 0) $Button5 = GUICtrlCreateButton("(Not allowed)", 120, 144, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\10sec.bmp", 0) $Button6 = GUICtrlCreateButton("(Not allowed)", 120, 184, 75, 27, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Documents and Settings\omnibook\Skrivbord\Z Clicker 1.1\Data\15 sec.bmp", 0) $Group1 = GUICtrlCreateGroup("Click Delay", 120, 80, 73, 25, BitOR($BS_CENTER,$BS_FLAT,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlCreateGroup("Click Delay", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) WEnd Case $Button2; PAUSAR While 1 endif WEnd Case $Button3;;;;;;OM EXIT DÅ EXIT Exit Case $Button4 While 1 MouseClick("left");;;;5 SEC DELAY CLICK sleep(5000) WEnd Case $Button5 While 1 MouseClick("left");;;;10 SEC DELAY CLICK sleep(10000) WEnd Case $Button6 While 1 MouseClick("left");;;;15 SEC DELAY CLICK sleep(15000) WEnd Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Edited March 31, 2008 by Zisly 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