sandman Posted April 6, 2007 Share Posted April 6, 2007 I have a function that is made to send "c" if a pixel is not red, and then keep checking (basically repeating, see code) if the pixel has gone back to red. I may not be able to figure it out just because I'm me , but let me get your feedback. Sorry if this isn't clear enough.. I can't describe it very well. Func AutoMP() $mpcheck = PixelGetColor(186, 28) $mpfull = PixelGetColor(264, 28) While 1 If $mpcheck = "000000" & $readmpstyle = "sit" Then Send("c") If $mpfull = "4758e4" Then Send("c") Else ContinueLoop EndIf EndIf If $mpcheck = "000000" & $readmpstyle = "pot" Then Do Send($readmpslot) _Timer(5000) ;Avoid lag messing up the script $readmppotamt -= 1 Until $mpcheck = "4758e4" EndIf If $mpcheck = "000000" & $readmpstyle = "both" Then If $readmppot > 0 Then Send($readmpslot) ElseIf $readmppot = 0 Then Send("c") ;INITIALLY SEND C If $mpfull = "4758e4" Then ;IF PIXEL IS RED, THEN Send("c") ;SEND C AGAIN Else ;IF PIXEL IS NOT RED.... ;WHAT DO I DO HERE???????????????????????????????????????????????? EndIf EndIf EndIf WEnd EndFunc I want to somehow have the script return to the "ElseIf $readmppot = 0 Then" line to check again, but I don't believe there is anything in AutoIt that resembles a GoToLine.. sigh. [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
GEOSoft Posted April 7, 2007 Share Posted April 7, 2007 I have a function that is made to send "c" if a pixel is not red, and then keep checking (basically repeating, see code) if the pixel has gone back to red. I may not be able to figure it out just because I'm me , but let me get your feedback. Sorry if this isn't clear enough.. I can't describe it very well. Func AutoMP() $mpcheck = PixelGetColor(186, 28) $mpfull = PixelGetColor(264, 28) While 1 If $mpcheck = "000000" & $readmpstyle = "sit" Then Send("c") If $mpfull = "4758e4" Then Send("c") Else ContinueLoop EndIf EndIf If $mpcheck = "000000" & $readmpstyle = "pot" Then Do Send($readmpslot) _Timer(5000) ;Avoid lag messing up the script $readmppotamt -= 1 Until $mpcheck = "4758e4" EndIf If $mpcheck = "000000" & $readmpstyle = "both" Then If $readmppot > 0 Then Send($readmpslot) ElseIf $readmppot = 0 Then Send("c") ;INITIALLY SEND C If $mpfull = "4758e4" Then ;IF PIXEL IS RED, THEN Send("c") ;SEND C AGAIN Else ;IF PIXEL IS NOT RED.... ;WHAT DO I DO HERE???????????????????????????????????????????????? EndIf EndIf EndIf WEnd EndFunc I think you shoud also be able to use Return in place of the function calling itself again but play with this first 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...
sandman Posted April 7, 2007 Author Share Posted April 7, 2007 I don't think Chk_Clr will work, because this will immediately 'replay' the function, and, when it sees that the pixel is still not red, it will send 'c' again. I will look into Return, though.. thanks! [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
sandman Posted April 7, 2007 Author Share Posted April 7, 2007 Hmm.. I looked in the helpfile.. I don't understand how Return() would work. Maybe this could, though: expandcollapse popup$sitting = 0 Func AutoMP() $mpcheck = PixelGetColor(186, 28) $mpfull = PixelGetColor(264, 28) While 1 If $mpcheck = "000000" & $readmpstyle = "sit" Then Send("c") If $mpfull = "4758e4" Then Send("c") Else ContinueLoop EndIf EndIf If $mpcheck = "000000" & $readmpstyle = "pot" Then Do Send($readmpslot) _Timer(5000) ;Avoid lag messing up the script $readmppotamt -= 1 Until $mpcheck = "4758e4" EndIf If $mpcheck = "000000" & $readmpstyle = "both" Then If $readmppot > 0 Then Send($readmpslot) ElseIf $readmppot = 0 Then If $sitting = 1 ContinueLoop ElseIf $sitting = 0 Send("c") ;INITIALLY SEND C If $mpfull = "4758e4" Then ;IF PIXEL IS RED, THEN Send("c") ;SEND C AGAIN Else ;IF PIXEL IS NOT RED.... $sitting = 1 ContinueLoop EndIf EndIf EndIf WEnd EndFunc Sorry.. the code is kind of jumbled up because I edited this in the web browser instead of SciTE, but would this work? [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
GEOSoft Posted April 7, 2007 Share Posted April 7, 2007 Hmm.. I looked in the helpfile.. I don't understand how Return() would work. Maybe this could, though: expandcollapse popup$sitting = 0 Func AutoMP() $mpcheck = PixelGetColor(186, 28) $mpfull = PixelGetColor(264, 28) While 1 If $mpcheck = "000000" & $readmpstyle = "sit" Then Send("c") If $mpfull = "4758e4" Then Send("c") Else ContinueLoop EndIf EndIf If $mpcheck = "000000" & $readmpstyle = "pot" Then Do Send($readmpslot) _Timer(5000) ;Avoid lag messing up the script $readmppotamt -= 1 Until $mpcheck = "4758e4" EndIf If $mpcheck = "000000" & $readmpstyle = "both" Then If $readmppot > 0 Then Send($readmpslot) ElseIf $readmppot = 0 Then If $sitting = 1 ContinueLoop ElseIf $sitting = 0 Send("c") ;INITIALLY SEND C If $mpfull = "4758e4" Then ;IF PIXEL IS RED, THEN Send("c") ;SEND C AGAIN Else ;IF PIXEL IS NOT RED.... $sitting = 1 ContinueLoop EndIf EndIf EndIf WEnd EndFunc Sorry.. the code is kind of jumbled up because I edited this in the web browser instead of SciTE, but would this work?Imeant that you could probably put Return in the Chk_Clr() func instead of calling Chk_Clr() again Else Return EndIf That will put you back into your While loop where ithe function was called. 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...
sandman Posted April 7, 2007 Author Share Posted April 7, 2007 But then that While loop would still just send me right back to Chk_Clr() again, wouldn't it? Then it would send 'c' again. This program I am trying to automate does not make the pixel red for about 20 to 30 seconds. The time duration changes, so Sleep() wouldn't work. Believe me, I would have tried that already. [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
Uten Posted April 7, 2007 Share Posted April 7, 2007 (edited) Refactor your code a bit and you will probably find logical errors easier. It will also make it easier to read.. My suggestion: expandcollapse popupFunc AutoMP() Local $continue $mpcheck = PixelGetColor(186, 28) $mpfull = PixelGetColor(264, 28) ;TODO: Why loop at all? You only read the color state once? Do If $mpcheck = "000000" & $readmpstyle = "sit" Then $continue = ActionSit($mpcheck, $mpfull) ElseIf $mpcheck = "000000" & $readmpstyle = "pot" Then $continue = ActionPot($mpcheck, $mpfull) ElseIf $mpcheck = "000000" & $readmpstyle = "both" Then $continue = ActionBoth($mpcheck, $mpfull) EndIf Until $continue EndFunc ; ; TODO: Explain what the function is all about Func ActionSit($mpcheck, $mpfull) Local $ret = 0 ;TODO: Does this make sence? Send("c") If $mpfull = "4758e4" Then Send("c") Else $ret = 1 ;ContinueLoop EndIf Return $ret EndFunc ; ; TODO: Explain what the function is all about Func ActionBoth($mpcheck, $mpfull) Local $ret = 0 If $readmppot > 0 Then Send($readmpslot) ElseIf $readmppot = 0 Then Send("c") ;INITIALLY SEND C If $mpfull = "4758e4" Then ;IF PIXEL IS RED, THEN Send("c") ;SEND C AGAIN Else ;IF PIXEL IS NOT RED.... ;WHAT DO I DO HERE???????????????????????????????????????????????? ;You probably read the pixel again and do some chceking or you just return or what ever. EndIf EndIf Return $ret EndFunc ; ; TODO: Explain what the function is all about Func ActionPot($mpcheck, $mpfull) Local $ret = 0 Do Send($readmpslot) _Timer(5000) ;Avoid lag messing up the script $readmppotamt -= 1 ;TODO: When is $mpcheck suposed to change? Until $mpcheck = "4758e4" Return $ret EndFunc Edited April 7, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
sandman Posted April 7, 2007 Author Share Posted April 7, 2007 (edited) Uten, that will work well, but two things: - I do need it to repeatedly check the pixel colors.. so replacing the Do... Until with a While... WEnd would still work? Or would that throw off $continue? - I am HORRIBLE at interpreting what scripts do just by reading the source.. can you explain this a little bit more? Also, $mpcheck will change at a random time.. that's why I need a While... WEnd loop. Edited April 7, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] 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