Ham123 Posted May 13, 2009 Share Posted May 13, 2009 (edited) This is an excerpt from the code im writing. Im sure it seems pretty ugly to those who are experts on this, but it satisfies me What I am attempting to do is the following: 1.) func close will always work 2.) bb function will work once, then the other functions will follow through, only once a certain pixelgetcolor test has been confirmed will it use it again (included later in script) 3.) After bb function has happened, func c will happen, and then only once the pixelgetcolor is confirmed will it run the .exe 4.) after func c, the same thing with func d. 5.) after func d has occured, and a pixelgetcolor has been confirmed, cal.exe will run, and once it has completed, i would like it to continue testing a pixelgetcolor until the pixelgetcolor has occured involving bb will it stop. So the thing i am having trouble with. How to make Func cal() looping only when a certain pixelgetcolor is confirmed, and after that, a different pixelgetcolor which will make the whole loop go back to Func bb? Would I do: CODE Func cal() While pixelgetcolor( x, y) <> 0x...... Then Wend Else run( "cal.exe" ) Endfunc Func return() If pixelgetcolor( x, y) = 0x......... Then (command to return to func bb?) Else (command to return to func cal?) Endfunc the code that i am attempting CODE Func Close() Exit EndFunc Func bb() Run( "z.exe" ) EndFunc Func c() While PixelGetColor( x, y) <> 0x........ Then WEnd Else Run( "cc.exe" ) EndFunc Func d() While Pixelgetcolor( x, y) <> 0x........Then WEnd Else Run( "rdd.exe" ) EndIf Func cal() While Pixelgetcolor( x, y) <> 0x...........Then WEnd Else Run( "cal.exe" ) EndIf Thanks a bunch! sorry for my noobness Edited May 13, 2009 by Ham123 Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 up! Link to comment Share on other sites More sharing options...
GEOSoft Posted May 13, 2009 Share Posted May 13, 2009 Please wait before bumping posts. Read my signature George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 Please wait before bumping posts. Read my signaturesorry, wont happen again. Link to comment Share on other sites More sharing options...
MattyD Posted May 13, 2009 Share Posted May 13, 2009 Not sure I entirely comprehend what you're trying to do but from what I can gather this may help... (Dude change your fuction names etc. to something meaningful!) While 1 $PxlColour = pixelgetcolor( x, y) Switch $PxlColour Case 0x.... DoSomething() Case 0x.... DoSomethingElse() EndSwitch Wend You can use ExitLoop under a case to break the while loop Matt Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 (edited) Not sure I entirely comprehend what you're trying to do but from what I can gather this may help... (Dude change your fuction names etc. to something meaningful!) While 1 $PxlColour = pixelgetcolor( x, y) Switch $PxlColour Case 0x.... DoSomething() Case 0x.... DoSomethingElse() EndSwitch Wend You can use ExitLoop under a case to break the while loop Matt I guess my main question is how to to loop back to a certain function? so Case 0x.... Do something() ;this would loop back to the first function (bb) Case 0x.... Dosomethingelse() ;this would loop back to the previous function (cal) the func names are just acronyms. Edited May 13, 2009 by Ham123 Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 bump! so now just trying to figure out a function that would loop back to the first function (bb) and another function which would loop back to the previous function (cal) Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 bump! so now just trying to figure out a function that would loop back to the first function (bb) and another function which would loop back to the previous function (cal)Please show the code that you now have with annotations of what you what to happen and where you would like for it to take place - like you did in your first post. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 (edited) code underlined is what im trying to figure out.CODEFunc bb() Run( "z.exe" )EndFuncother code here Func cal() While pixelgetcolor( x, y) <> 0x...... Then Wend Else run( "cal.exe" )EndfuncFunc return() If pixelgetcolor( x, y) = 0x......... Then (command to return to func bb?) Else (command to return to func cal?)Endfunc Edited May 13, 2009 by Ham123 Link to comment Share on other sites More sharing options...
GEOSoft Posted May 13, 2009 Share Posted May 13, 2009 Func return() If pixelgetcolor( x, y) = 0x......... Then bb() Else cal() Endfunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 Func return() If pixelgetcolor( x, y) = 0x......... Then bb() Else cal() Endfunc oh lol, but will it actually loop back? or will it just execute that function? Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 (edited) First - this is not valid codeWhile pixelgetcolor( x, y) <> 0x...... Then WendSecond - this is not valid code - missing an EndIfFunc return() If pixelgetcolor( x, y) = 0x......... Then (command to return to func bb?) Else (command to return to func cal?)EndfuncThird - your sample code does not show how/where/when you called the func named bbForth - naming a Func "Return" is not allowed as there is a built in func named "Return" and that is what you want to use to return to "bb".Edit2: Technically, you can name the EDF "Return" - you just cannot call it.Edit: post some working code or valid pseudo code because it matters where/how you call the bb function - to avoid recursion. Edited May 13, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 (edited) First - this is not valid codeWhile pixelgetcolor( x, y) <> 0x...... Then WendSecond - this is not valid code - missing an EndIfFunc return() If pixelgetcolor( x, y) = 0x......... Then (command to return to func bb?) Else (command to return to func cal?)EndfuncThird - your sample code does not show how/where/when you called the func named bbForth - naming a Func "Return" is not allowed as there is a built in func named "Return" and that is what you want to use to return to "bb".Edit: post some working code or valid pseudo code because it matters where/how you call the bb function - to avoid recursion.The code you posted was typed up quickly, sorry i didnt make myself clear. i understand what i did wrong in them. I also know that return is not allowed as a function.Basically this:Func rtrn() If pixelgetcolor( x, y) = 0x......... Then (command to return to func bb?) Else (command to return to func cal?) EndifEndfuncjust want to know how to loop back is all.EDIT: (sorry didnt see this)as to the function BB its just a beginbutton. When the user presses a button then it automatically starts this function which runs z.exe Edited May 13, 2009 by Ham123 Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 (edited) bb() Func rtrn() If PixelGetColor(1, 1) = 0x000000 Then ;(command To Return To Func bb?) Return Else ;(command To Return To Func cal?) Return EndIf EndFunc ;==>rtrn Func bb() rtrn() EndFunc ;==>bb Func cal() rtrn() EndFunc ;==>calEdit: I doubt that this will do what you want - it is more to show what I meant by saying that it matters where you call the bb func from. Knowing what you are attempting to accomplish with your code might help us to help you. Edited May 13, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 ... as to the function BB its just a beginbutton. ...So we are talking part of your own GUI - right? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 (edited) bb() Func rtrn() If PixelGetColor(1, 1) = 0x000000 Then ;(command To Return To Func bb?) Return Else ;(command To Return To Func cal?) Return EndIf EndFunc ;==>rtrn Func bb() rtrn() EndFunc ;==>bb Func cal() rtrn() EndFunc ;==>calEdit: I doubt that this will do what you want - it is more to show what I meant by saying that it matters where you call the bb func from. Knowing what you are attempting to accomplish with your code might help us to help you. Ah its a very simple code CODE Func bb() ;beginbutton for users Run( "z.exe") ;beings first part endfunc func ___() ;begins next function While pixelgetcolor( x, y) <> 0x000000 ;performs pixel test, if not true, keeps doing it till is true. Wend Else ;if it is true, then runs Run( ".exe") ;whichever exe endfunc func ___() ;begins next function While pixelgetcolor( x, y) <> 0x000000 ;performs pixel test, if not true, keeps doing it till is true. Wend Else ;if it is true, then runs Run( ".exe") ;whichever exe endfunc func cal() ;begins next function While pixelgetcolor( x, y) <> 0x000000 ;performs pixel test, if not true, keeps doing it till is true. Wend Else ;if it is true, then runs Run( "cal.exe") ;whichever exe endfunc func rtrn() ;loops back to function BB or function cal If pixelgetcolor( x, y) = 0x000000 ;performs pixel test, if true goes to bb, else goes to cal COMMAND to go to BB else COMMAND to go to CAL Endif Endfunc So we are talking part of your own GUI - right? Yup. EDIT: so basically need to find out what those command would be. to loop back to bb or cal. EDIT2: by loop back, i mean actually loop back. if it goes to bb it will execute the file, then continue on with the other functions till it hits func rtrn() Edited May 13, 2009 by Ham123 Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 Where in your sample code do you call the func named rtrn() [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 Where in your sample code do you call the func named rtrn()After func cal has executed. func rtrn() is executed. func rtrn's pixelgetcolor is true, then it goes back to BB, else it goes to CAL.sry if that didnt answer your question, i guess i dont exactly understand what you're asking. Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 Just because you place a func in the script does not mean that it will run... you have to call it. Please run this code from within the SciTE editor:Func cal() ;begins next function MsgBox(0, "cal", "Did this msgbox appear?") EndFunc ;==>cal Func rtrn() ;loops back to function BB or function cal MsgBox(0, "rtrn", "Did this msgbox appear?") EndFunc ;==>rtrnoÝ÷ Ù8^Ú-ëì"¶aÇ(u殶sf6 §'G&â ¤gVæ26¶&Vvç2æWBgVæ7Föà¤×6t&÷ÂgV÷C¶6ÂgV÷C²ÂgV÷C´FBF2×6v&÷V#ògV÷C²¤VæDgVæ2³ÓÒfwC¶6À ¤gVæ2'G&â¶Æö÷2&6²FògVæ7Föâ$"÷"gVæ7Föâ6À¤×6t&÷ÂgV÷C·'G&âgV÷C²ÂgV÷C´FBF2×6v&÷V#ògV÷C²¤VæDgVæ2³ÓÒfwC·'G&à [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Ham123 Posted May 13, 2009 Author Share Posted May 13, 2009 (edited) Just because you place a func in the script does not mean that it will run... you have to call it. Please run this code from within the SciTE editor:Func cal() ;begins next function MsgBox(0, "cal", "Did this msgbox appear?") EndFunc ;==>cal Func rtrn() ;loops back to function BB or function cal MsgBox(0, "rtrn", "Did this msgbox appear?") EndFunc ;==>rtrnƒoÝŠ÷ Ù8^Ú-…ë™ì"¶aŠÇ(u殶ˆsf6‚ §'G&â‚ ¤gVæ26‚’¶&Vv–ç2æW‡BgVæ7F–öà¤×6t&÷‚ƒÂgV÷C¶6ÂgV÷C²ÂgV÷C´F–BF†—2×6v&÷‚V#ògV÷C²¤VæDgVæ2³ÓÒfwC¶6À ¤gVæ2'G&â‚’¶Æö÷2&6²FògVæ7F–öâ$"÷"gVæ7F–öâ6À¤×6t&÷‚ƒÂgV÷C·'G&âgV÷C²ÂgV÷C´F–BF†—2×6v&÷‚V#ògV÷C²¤VæDgVæ2³ÓÒfwC·'G&à ah lol. ok so. basically then it would be CODE while 1 bb() other func here() other func here() other func here() cal() If pixelgetcolor(x, y) = 0x000000 Then wend Else cal() Endif Func bb () stuff here endfunc other funcs func cal() stuff here end func Am i correct in this? it would go through bb other other other cal then pixel test, if true, goes to bb else goes to cal. after cal will go through pixel test one more time to see if its true or not? Edited May 13, 2009 by Ham123 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