Qsert18 Posted May 15, 2011 Posted May 15, 2011 (edited) hey guys, I've got this situation: i've got a script running in a script. This is the gui script (which include the other script: dossing paint) As u can see: u have to input a value, which decides how many times the "dossing paint" will run At a certain point: the dossing paint programm will stop, i want it to go back to the gui script and let it start over again. But with the "exit" code i'm using right now: it just stop the whole programm (all though i just mention it in the dossing paint.au3 :s It's quite diffecult to explain, but i hope you get it: résumé: So: how can i let a script stop working, but let the greater programm continue expandcollapse popup#include <GUIConstants.au3> ;settings: exit and start keys HotKeySet ( "{F6}", 'end') ;===================================== GUICreate("Dossing paint", 250, 150) GUISetFont(12) $pass = InputBox ("Dossing paint", "please enter your password","","*",250,150) GUICtrlCreateLabel("how many games should I run?", 4, 4) $put1 = GUICtrlCreateInput("number", 4, 25, 200, 25) $send = GUICtrlCreateButton("Start", 4, 60, 150, 25) GUISetState() While 1 $msg = GUIGetMsg() If $pass <> "password" Then $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?") If $WrongPass = 1 Then $pass = InputBox ("enter password", "please enter your password","","*",250,150) ElseIf $WrongPass = 2 Then $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm") ExitLoop EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $send Then SendMyData () WEnd Func SendMyData() $i = 0 do #include <dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc Func end() Exit 0 endfunc This is dossing paint.au3 $pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) Exit EndIf So as u can see: if the color changed into 0xfff46A than i would just like to stop this dossing paint.au3 and let the gui script do it all over again (do, untill loop) closer look @the do untill loop Func SendMyData() $i = 0 do #include <dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc So let's say i input a value 7, than i want dossing paint to run 7x. If dossing paint ends, than i would just like to do it another 6x Any solution for the "exit script problem"? Edited May 15, 2011 by Qsert18
martin Posted May 15, 2011 Posted May 15, 2011 On 5/15/2011 at 1:23 PM, 'Qsert18 said: hey guys, I've got this situation: i've got a script running in a script. This is the gui script (which include the other script: dossing paint) As u can see: u have to input a value, which decides how many times the "dossing paint" will run At a certain point: the dossing paint programm will stop, i want it to go back to the gui script and let it start over again. But with the "exit" code i'm using right now: it just stop the whole programm (all though i just mention it in the dossing paint.au3 :s It's quite diffecult to explain, but i hope you get it: résumé: So: how can i let a script stop working, but let the greater programm continue expandcollapse popup#include <GUIConstants.au3> ;settings: exit and start keys HotKeySet ( "{F6}", 'end') ;===================================== GUICreate("Dossing paint", 250, 150) GUISetFont(12) $pass = InputBox ("Dossing paint", "please enter your password","","*",250,150) GUICtrlCreateLabel("how many games should I run?", 4, 4) $put1 = GUICtrlCreateInput("number", 4, 25, 200, 25) $send = GUICtrlCreateButton("Start", 4, 60, 150, 25) GUISetState() While 1 $msg = GUIGetMsg() If $pass <> "password" Then $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?") If $WrongPass = 1 Then $pass = InputBox ("enter password", "please enter your password","","*",250,150) ElseIf $WrongPass = 2 Then $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm") ExitLoop EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $send Then SendMyData () WEnd Func SendMyData() $i = 0 do #include <dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc Func end() Exit 0 endfunc This is dossing paint.au3 $pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) Exit EndIf So as u can see: if the color changed into 0xfff46A than i would just like to stop this dossing paint.au3 and let the gui script do it all over again (do, untill loop) closer look @the do untill loop Func SendMyData() $i = 0 do #include <dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc So let's say i input a value 7, than i want dossing paint to run 7x. If dossing paint ends, than i would just like to do it another 6x Any solution for the "exit script problem"? AT a quick look I think you have misunderstood what th einclude is doing. All #include does is to replace the #iclude line with the text that is in the include file. SO you don't have another script running at all so exit stops the script not just the function you called. . I think you need to change it to something like this Func SendMyData() $i = 0 do _DosPaint();dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc Add #iclude "dossing paint.au3" at the top of your script with other includes, then change dossingpaint.au3 to something like this Func _DosPaint() $pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) return; not exit EndIf endfunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Qsert18 Posted May 16, 2011 Author Posted May 16, 2011 (edited) euhm ok...but it still ain't doing what i would like it to do. I made a simplified version of the scripts. I'll post them here 1st: (the gui.au3 file) expandcollapse popup#include <GUIConstants.au3> ;settings: exit and start keys HotKeySet ( "{F6}", 'end') ;===================================== GUICreate("Dossing paint", 250, 150) GUISetFont(12) $pass = InputBox ("Dossing paint", "please enter your password","","*",250,150) GUICtrlCreateLabel("how many games should I run?", 4, 4) $put1 = GUICtrlCreateInput("number", 4, 25, 200, 25) $send = GUICtrlCreateButton("Start", 4, 60, 150, 25) GUISetState() While 1 $msg = GUIGetMsg() If $pass <> "password" Then $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?") If $WrongPass = 1 Then $pass = InputBox ("enter password", "please enter your password","","*",250,150) ElseIf $WrongPass = 2 Then $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm") ExitLoop EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $send Then SendMyData () WEnd Func SendMyData() $i = 0 do _DosPaint();dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc Func end() Exit 0 endfunc and now the function itself: expandcollapse popup; ; AutoIt Version: 3.0 ; Language: English ; Author: Stefan ; ; Script Function: ;dossing paint ;settings: type slower AutoItSetOption ("SendKeyDelay", 100) ;var' $Pixel1 = PixelGetColor(769, 532) sleep (5000) MouseClick("left", 304, 871, 1) sleep (500) MouseClick("left", 845,236, 2) sleep (500) MouseClick("left", 910,237, 2) sleep (500) MouseClick("left", 304, 871, 1) sleep (1000) ;--------------------------------------------------------------------------------------------------------------------------------- Func _DosPaint() $pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) return; not exit EndIf endfunc $pixel2 = pixelsearch ( 515, 241, 890, 322, 0xAA0303 ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) EndIf MouseClick("left", 304, 871, 1) sleep (500) MouseClick("left", 845,236, 2) sleep (500) MouseClick("left", 910,237, 2) sleep (500) MouseClick("left", 304, 871, 1) sleep (5000) I don't think i can use "endfunc" in this, since it has to be something INSIDE the if/endif statement (endfunc can only be put after endif :s). So what i basically want: 1. u start the gui 2. it will ask u a password ( just cool stuff ) 3. it will ask you how many times u want to run dospaint.au3 4. it will run dospaint.au3 5. it will make 4 clicks 6. If the color is gold/red in the paint window than i would like it to stop the dospaint.au3 BUT continue with the gui.au3 (and so restart the dospaint.au3). So for example: i wanted it to run dospaint.au3 3x, than dospaint.au3 will end in the middle of the script and than run another 2x Thanks in advance kind regards, stefan PS: thanks for ur fast reply of yesterday Edited May 16, 2011 by Qsert18
Arterie Posted May 16, 2011 Posted May 16, 2011 (edited) i dont really get what it should do but anyways... if you want to call _DosPaint youll need to put #include <dossing paint.au3> at the top of the gui.au3 Edited May 16, 2011 by Arterie
sleepydvdr Posted May 16, 2011 Posted May 16, 2011 I'm not 100% sure of what you are trying to accomplish, but why not build the dossingpaint.au3 into your script as one function? This runs it and when it's finished, the GUI continues to run: expandcollapse popup#include <GUIConstants.au3> ;settings: exit and start keys HotKeySet ( "{F6}", 'end') ;===================================== GUICreate("Dossing paint", 250, 150) GUISetFont(12) $pass = InputBox ("Dossing paint", "please enter your password","","*",250,150) GUICtrlCreateLabel("how many games should I run?", 4, 4) $put1 = GUICtrlCreateInput("number", 4, 25, 200, 25) $send = GUICtrlCreateButton("Start", 4, 60, 150, 25) GUISetState() While 1 $msg = GUIGetMsg() If $pass <> "password" Then $WrongPass = MsgBox (1,"warning" , "incorrect password" & @CRLF & "TRY AGAIN ?") If $WrongPass = 1 Then $pass = InputBox ("enter password", "please enter your password","","*",250,150) ElseIf $WrongPass = 2 Then $Exting = MsgBox (0,"Exiting" , "Due to cancelation by user.." & @CRLF & "Now exiting the programm") ExitLoop EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $send Then SendMyData () WEnd Func SendMyData() $i = 0 do _DosPaint();dossing paint.au3> ; sleep (50) $i = $i + 1 until $i = GUICtrlRead ($put1) EndFunc Func end() Exit 0 endfunc Func _DosPaint() AutoItSetOption ("SendKeyDelay", 100) ;var' $Pixel1 = PixelGetColor(769, 532) sleep (5000) MouseClick("left", 304, 871, 1) sleep (500) MouseClick("left", 845,236, 2) sleep (500) MouseClick("left", 910,237, 2) sleep (500) MouseClick("left", 304, 871, 1) sleep (1000) $pixel1 = pixelsearch ( 515, 241, 890, 322, 0xFFF46A ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) return; not exit EndIf $pixel2 = pixelsearch ( 515, 241, 890, 322, 0xAA0303 ) If IsArray ($pixel1) = true then MouseClick("left",695,560,2) sleep (15000) mouseclick ( "left", 1048, 733, 1, 2) EndIf MouseClick("left", 304, 871, 1) sleep (500) MouseClick("left", 845,236, 2) sleep (500) MouseClick("left", 910,237, 2) sleep (500) MouseClick("left", 304, 871, 1) sleep (5000) endfunc #include <ByteMe.au3>
martin Posted May 16, 2011 Posted May 16, 2011 On 5/16/2011 at 4:04 PM, 'Qsert18 said: bump First please be a little more patient. Bumping your post after only a few hours is daft IMO. Bumping a post is not like rubbing a magic lantern . You need to grasp some fundamentals, and you need to pay attention. I say that because what I showed in my first reply was largely lost or not understood. Ignore what you want to do in your script for a minute. Imagine you have this script. For $n = 1 To 100 If Mod($n, 3) = 0 Then ConsoleWrite($n * $n / 3 & @CRLF) EndIf Next MsgBox(262144, "All done", "ok") That can be done like this For $n = 1 To 100 _DoTheIfBit($n) Next _SayBye() func _DoTheIfBit($i) If Mod($i, 3) = 0 Then _WriteAns($i * $i / 3) EndIf EndFunc Func _WriteAns($a) ConsoleWrite($a & @CRLF) EndFunc func _SayBye() MsgBox(262144, "All done", "ok") EndFunc .. and that can be done like this #include "myAmazingFunctions.au3" For $n = 1 To 100 _DoTheIfBit($n) Next _SayBye() where there is a file called "myAmazingFunctions.au3" as below func _DoTheIfBit($i) If Mod($i, 3) = 0 Then _WriteAns($i * $i / 3)ConsoleWrite($i * $i / 3 & @CRLF) EndIf EndFunc Func _WriteAns($a) ConsoleWrite($a & @CRLF) EndFunc func _SayBte() MsgBox(262144, "All done", "ok") EndFunc When you have understood that, which means reading it, thinking about it, changing it and convincing yourself that you get it and that you can do it, and you could explain to someone else how to do it, then look at what you want to do with your script again. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Qsert18 Posted May 16, 2011 Author Posted May 16, 2011 Quote i dont really get what it should do but anyways... Quote I'm not 100% sure of what you are trying to accomplishI'm just trying some stuff out in paint, so i can make the programm i have in mind later (paint is quite easy for the color stuff ) Quote but why not build the dossingpaint.au3 into your script as one function?Well: my script was becoming quite a chaos (a bit big) i just posted a simplified version of it.Though, i'm putting my both scripts together now, since the script u posted works like i wanted it to.Thanks for ur replies, problem solved now =) Quote #include <dossing paint.au3> at the top of the gui.au3If i do this, than it will 1st run dossing paint.au3 and afterwards my gui.au3.
Qsert18 Posted May 16, 2011 Author Posted May 16, 2011 (edited) i was just bumping my post cause it was at the bottom of the list (so i thought nobody would read it anymore) Quote You need to grasp some fundamentals, and you need to pay attention.100% true atm: checking the post u just posted, will edit this msg afterwardswhat text editor supports this console write? Ain't working in notepad, notepad++, or anything else i'm not fully understanding this "console write"...never saw it before and the help file is quite vague about it (well quite vague to me = i don't understand it ) Edited May 16, 2011 by Qsert18
martin Posted May 16, 2011 Posted May 16, 2011 On 5/16/2011 at 5:45 PM, 'Qsert18 said: i was just bumping my post cause it was at the bottom of the list (so i thought nobody would read it anymore)100% true atm: checking the post u just posted, will edit this msg afterwardswhat text editor supports this console write? Ain't working in notepad, notepad++, or anything else i'm not fully understanding this "console write"...never saw it before and the help file is quite vague about it (well quite vague to me = i don't understand it )Have a look at SciTE. I think most people in these forums use it. It will make your life a lot easier. Install it, open a file, or start a new one and save as an au3 file. Use Ctrl T to format the code, it works brilliantly, use F1 to open the AutoIt help at the word under the cursor, use F5 to run a script, use Ctrl F7 to compile it. Many many more features. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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