Pyrex Posted June 11, 2008 Share Posted June 11, 2008 I having a problem with this: If PixelGetColor(328,84) <> 41216 Then Send ("{TAB}") EndIf If ((PixelGetColor(328,84) = 41216) And (PixelGetColor(254,977) = 10066329)) Then Send ("1") Sleep(1700) Else Sleep(1700) Send("{UP down}") Sleep (3000) Send("{UP up}") Sleep(5000) EndIf As you can see, I firstly want it to check and see if it's got the colour. Then if not, it will Tab. Then the second part I need it to check 2 colours and they need to both be there, otherwise I want it to press UP for 3 seconds. I can see on my screen that they are both there, but it just seems to skip to the 'Else' part. I'm a bit confused as if it's Else or ElseIf. I'm not sure what the difference is. Link to comment Share on other sites More sharing options...
sandin Posted June 11, 2008 Share Posted June 11, 2008 if you have only 2 stipulations use IF...ELSE...ENDIF example: if $i true Then ;do some stuff Else ;do something else EndIf Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
GEOSoft Posted June 11, 2008 Share Posted June 11, 2008 (edited) I having a problem with this: If PixelGetColor(328,84) <> 41216 Then Send ("{TAB}") EndIf If ((PixelGetColor(328,84) = 41216) And (PixelGetColor(254,977) = 10066329)) Then Send ("1") Sleep(1700) Else Sleep(1700) Send("{UP down}") Sleep (3000) Send("{UP up}") Sleep(5000) EndIf As you can see, I firstly want it to check and see if it's got the colour. Then if not, it will Tab. Then the second part I need it to check 2 colours and they need to both be there, otherwise I want it to press UP for 3 seconds. I can see on my screen that they are both there, but it just seems to skip to the 'Else' part. I'm a bit confused as if it's Else or ElseIf. I'm not sure what the difference is.They might both be there but are they at the coordinates you gave? Easy test. MsgBox(0, "TEST", PixelGetColor(328,84)) MsgBox(0, "TEST", PixelGetColor(254,977)) Edited June 11, 2008 by GEOSoft 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...
Pyrex Posted June 12, 2008 Author Share Posted June 12, 2008 They might both be there but are they at the coordinates you gave? Easy test. MsgBox(0, "TEST", PixelGetColor(328,84)) MsgBox(0, "TEST", PixelGetColor(254,977)) yeah both are correct Link to comment Share on other sites More sharing options...
GEOSoft Posted June 12, 2008 Share Posted June 12, 2008 (edited) yeah both are correctI suspect that you need a sleep after the first If. You are sending the tab but I think before it gets a chance to change you checking the pixels. Try Local $a = 0, $b = 0 If ((PixelGetColor(328,84) = 41216) And (PixelGetColor(254,977) = 10066329)) Then $a = PixelGetColor(328,84) $b = PixelGetColor(254,977) Send ("1") Sleep(1700) Else Sleep(1700) Send("{UP down}") Sleep (3000) Send("{UP up}") Sleep(5000) EndIf MsgBox(0, "TEST", $a & @CRLF & $b) That should tell you pretty much for sure. Edited June 12, 2008 by GEOSoft 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...
Pyrex Posted June 12, 2008 Author Share Posted June 12, 2008 I suspect that you need a sleep after the first If. You are sending the tab but I think before it gets a chance to change you checking the pixels. Try Local $a = 0, $b = 0 If ((PixelGetColor(328,84) = 41216) And (PixelGetColor(254,977) = 10066329)) Then $a = PixelGetColor(328,84) $b = PixelGetColor(254,977) Send ("1") Sleep(1700) Else Sleep(1700) Send("{UP down}") Sleep (3000) Send("{UP up}") Sleep(5000) EndIf MsgBox(0, "TEST", $a & @CRLF & $b) That should tell you pretty much for sure.It presses 1 then brings up the message box saying "41216 10066329" Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 12, 2008 Share Posted June 12, 2008 It presses 1 then brings up the message box saying "41216 10066329"...and what did you want it to do? Those values indicate the If condition was satisfied, so it did what it was coded to do. What else did you want it to do...?Your first post started out with testing only one of the pixels, and only for "<>". Then you tested for "=" on two pixels. What is the relationship between the two? Is hitting TAB supposed to change the pixel color so it could match on the next test, or are they unrelated? If the first pixel was "<>", then did you need to text the second one at all? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted June 12, 2008 Share Posted June 12, 2008 I suspect that If you change the code that I gave you to what is below, you will find that the Else is in fact NOT being triggered which is what you wanted. ; Local $a = 0, $b = 0, $c = 0 If ((PixelGetColor(328,84) = 41216) And (PixelGetColor(254,977) = 10066329)) Then $a = PixelGetColor(328,84) $b = PixelGetColor(254,977) Send ("1") Sleep(1700) Else Sleep(1700) Send("{UP down}") Sleep (3000) Send("{UP up}") Sleep(5000) $c = 1 EndIf MsgBox(0, "TEST", $a & @CRLF & $b & @CRLF & $c) ; 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...
Pyrex Posted June 12, 2008 Author Share Posted June 12, 2008 I want it to:Firstly, it won't have a selected target. So the colour will be different than 41216. So therefore it has to press tab (which is the button to select a target), (Which is what I want it to do).Then, I want it to make sure it's selected the target. So it will check for 41216 and it should be true.Then I want it to make sure the target is not out of range. By searching for the colour 10066329.If both colours are true, I want it to start attacking (1).If either one is false, I want it to run (up key) for 3 seconds, then start from the top. 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