SilverSky Posted December 21, 2012 Share Posted December 21, 2012 (edited) HI, I have a problemHow to insert my function on this scriptOk this is my script :While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $Button1 For $i = 1 To 1000 MouseMove (356, 400) Sleep(500) MouseClick("primary", 356, 400) Sleep(2000) MouseMove(750, 654 ) Sleep(500) MouseClick("primary", 750, 654) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(677,612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(866, 697) Sleep(500) MouseClick("primary", 866, 697) Sleep(300000) Next <---I would like to have this function EndSwitch WEndMy Function:Func Pauza() $Paused = NOT $Paused While $Paused sleep(100) ToolTip("Text",0,0) WEnd EndFuncSORRY FOR MY BAD ENGLISH Edited December 21, 2012 by SilverSky Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 21, 2012 Moderators Share Posted December 21, 2012 (edited) Hi, SilverSky, welcome to the forum. First off, I would suggest a more descriptive title in the future. Secondly, have you looked at the examples for Func in the help file? They do a pretty good job of showing you how to properly call the function. All you need to do is add the call to the function (Pauza() in your case) at whatever point in the script you would like it to run. Edited December 21, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
SilverSky Posted December 21, 2012 Author Share Posted December 21, 2012 I wish this function is called by the $Button2 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $Button1 For $i = 1 To 1000 MouseMove (356, 400) Sleep(500) MouseClick("primary", 356, 400) Sleep(2000) MouseMove(750, 654 ) Sleep(500) MouseClick("primary", 750, 654) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(677,612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(866, 697) Sleep(500) MouseClick("primary", 866, 697) Sleep(300000) Next Case $Button2 <---I would like to have this function EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 21, 2012 Moderators Share Posted December 21, 2012 Then look at the example in the help file under Func and you'll see how to do it "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
SilverSky Posted December 21, 2012 Author Share Posted December 21, 2012 Ok, i'm stuck... expandcollapse popupFunc TogglePaused() $Paused = Not $Paused While $Paused Sleep(100) TrayTip("NosTale", "Pauza", 5, 1) WEnd EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $Button1 For $i = 1 To 1000 MouseMove (356, 400) Sleep(500) MouseClick("primary", 356, 400) Sleep(2000) MouseMove(750, 654 ) Sleep(500) MouseClick("primary", 750, 654) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(677,612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(866, 697) Sleep(500) MouseClick("primary", 866, 697) Sleep(300000) Next Case $Button2 TogglePaused() EndSwitch WEnd looks alright ? but when i open my script this error block me: WARNING: $Paused: possibly used before declaration. Link to comment Share on other sites More sharing options...
kylomas Posted December 21, 2012 Share Posted December 21, 2012 (edited) SilverSky, First, to get help you will need to post something that is runnable. Secondly, when button 1 is actioned your script will become unresponive for the next 83+ hours, probably not what you want. To solve this, see M23's excellent article for interrupting running functions. Do a search for it. In case you want to test this for yourself, run the following expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n local $paused = false Local $gui010 = GUICreate('Mouse Clicking Hell') Local $Button1 = GUICtrlCreateButton('#1', 10, 10, 200, 20) Local $Button2 = GUICtrlCreateButton('#2', 10, 50, 200, 20) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE exit Case $Button1 For $i = 1 To 1000 MouseMove(356, 400) Sleep(500) MouseClick("primary", 356, 400) Sleep(2000) MouseMove(750, 654) Sleep(500) MouseClick("primary", 750, 654) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(866, 697) Sleep(500) MouseClick("primary", 866, 697) Sleep(300000) Next Case $Button2 pauza() EndSwitch WEnd Func Pauza() $Paused = Not $Paused While $Paused Sleep(100) ToolTip("Text", 0, 0) WEnd EndFunc ;==>Pauza kylomas edit: clarification - have button 1 call a function and make that function interruptible following the doc that I pointed you to. Edited December 21, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 21, 2012 Share Posted December 21, 2012 That warning message should say, "$Paused USED before declaration", and you should read the Help file. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Xandy Posted December 21, 2012 Share Posted December 21, 2012 (edited) throw: global $paused= 0 as the first line of your script, before the func TogglePaused() Edited December 21, 2012 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
SilverSky Posted December 21, 2012 Author Share Posted December 21, 2012 (edited) Ok but when i run first option $Button1: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $Button1 For $i = 1 To 1000 MouseMove (356, 400) Sleep(500) MouseClick("primary", 356, 400) Sleep(2000) MouseMove(750, 654 ) Sleep(500) MouseClick("primary", 750, 654) Sleep(2000) MouseMove(677, 612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(677,612) Sleep(500) MouseClick("primary", 677, 612) Sleep(2000) MouseMove(866, 697) Sleep(500) MouseClick("primary", 866, 697) Sleep(300000) global $paused= 0 Func TogglePaused() $Paused = Not $Paused While $Paused Sleep(100) TrayTip("NosTale", "Pauza", 5, 1) WEnd EndFunc func. still doesent stop option 1 $Button1 :/ but when i click first option 2 $Button2 option works... Edited December 21, 2012 by SilverSky Link to comment Share on other sites More sharing options...
kylomas Posted December 21, 2012 Share Posted December 21, 2012 SilverSky, It will be impossible to help you unless you read and understand each reply to your topic. Re-read reply #6. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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