Engineer Posted August 26, 2011 Share Posted August 26, 2011 $pixle2 = PixelSearch(389, 144, 436, 180, 0xCA372D) If IsArray($pixle2) Then If PixelSearch(389, 144, 406, 162, 0xCA372D) Then MsgBox(1, "its Here", "its here") EndIf Else MsgBox(1, "nothing", "Nothing") EndIf this code works when there is nothing found. but when it does find something, it doesn't pop up the msg box"its here". I know theres probably a simple soulution, but I can't see it. some help would be apricated. Link to comment Share on other sites More sharing options...
Spiff59 Posted August 26, 2011 Share Posted August 26, 2011 (edited) You have no else condition for your second "If" statement. If the first If is true, and the second is false, the program goes on to the next statement without any message displayed. Edit: In other words, it's not finding something (your target color value at that specific coordinate), but $pixle2 is an array. Edited August 26, 2011 by Spiff59 Link to comment Share on other sites More sharing options...
Engineer Posted August 26, 2011 Author Share Posted August 26, 2011 $pixle2 = PixelSearch(309, 145, 347, 179, 0xCA372D) If IsArray($pixle2) Then If PixelSearch(309, 145, 323, 161, 0xCA372D) Then MsgBox(1, "its Here", "its here") Else EndIf Else MsgBox(1, "nothing", "Nothing") EndIf I've added the end if. the point of the program is to locate the pixel in a generalized area, then localize the search to a smaller area. this time its not bringing up the Nothing MSGBOX, but it still won't display the its here MSGBOX. still confused.(as usuall) Link to comment Share on other sites More sharing options...
hannes08 Posted August 26, 2011 Share Posted August 26, 2011 $pixle2 = PixelSearch(309, 145, 347, 179, 0xCA372D) If IsArray($pixle2) Then If PixelSearch(309, 145, 323, 161, 0xCA372D) Then MsgBox(1, "its Here", "its here") Else ; <<<<<<<<<<<<<< Let's see what we missed here .... EndIf Else MsgBox(1, "nothing", "Nothing") EndIf Script logical fault in line marked with "<<<<<..." Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Engineer Posted August 27, 2011 Author Share Posted August 27, 2011 Call me an idiot, but the way you had it doesn't work. Obviously something has to go in there, but I don't want it to do any thing. just 2 possible outcomes for 3 variables. any advice? Link to comment Share on other sites More sharing options...
czardas Posted August 27, 2011 Share Posted August 27, 2011 (edited) $sMsg = "nothing" $pixle2 = PixelSearch(389, 144, 436, 180, 0xCA372D) If IsArray($pixle2) And IsArray(PixelSearch(389, 144, 406, 162, 0xCA372D)) Then $sMsg = "its Here" MsgBox(1, $sMsg, $sMsg) Is this what you want? Edited August 27, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Engineer Posted September 1, 2011 Author Share Posted September 1, 2011 the and really helped. but just out of curosity, how am I susposed to make it do an action only when the second part is false and the first part is true. like $pixle2 =true + the AND is false=do action 1 $pixle2=true + the AND is true=do action 2 $pixle2=false+the AND is false=do nothing there can't be another out come since the second pixle search is a possible part of the picture its scaning. its rather confusing, all in all. Link to comment Share on other sites More sharing options...
JohnOne Posted September 1, 2011 Share Posted September 1, 2011 $pixle2 = PixelSearch(389, 144, 436, 180, 0xCA372D) If IsArray($pixle2) Then $Temp = PixelSearch(389, 144, 406, 162, 0xCA372D) If IsArray($Temp) Then MsgBox(1, "its Here", "its here") EndIf Else MsgBox(1, "nothing", "Nothing") EndIf AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted September 1, 2011 Share Posted September 1, 2011 (edited) how am I susposed to make it do an action only when the second part is false and the first part is true. like $pixle2 =true + the AND is false=do action 1 $pixle2=true + the AND is true=do action 2 $pixle2=false+the AND is false=do nothing Work through it logically like this: $pixle2 = PixelSearch(389, 144, 436, 180, 0xCA372D) If IsArray($pixle2) Then $Temp = PixelSearch(389, 144, 406, 162, 0xCA372D) If IsArray($Temp) Then ; Both searches yielded results MsgBox(1, "Doing", "Action 2") ; Perform Action 2 Else ; The previous If statement was false MsgBox(1, "Doing", "Action 1") ; Perform Action 1 EndIf Else ; This else statement is not needed (see the next version) MsgBox(1, "Not needed", "Nothing in particular") ; Code for doing nothing EndIf So we can simplify the above code to get: $pixle2 = PixelSearch(389, 144, 436, 180, 0xCA372D) If IsArray($pixle2) Then $Temp = PixelSearch(389, 144, 406, 162, 0xCA372D) If IsArray($Temp) Then MsgBox(1, "Doing", "Action 2") ; Perform Action 2 Else MsgBox(1, "Doing", "Action 1") ; Perform Action 1 EndIf EndIf OR (if you are not interested in the pixel's coordinates) If IsArray(PixelSearch(389, 144, 436, 180, 0xCA372D)) Then If IsArray(PixelSearch(389, 144, 406, 162, 0xCA372D)) Then MsgBox(1, "Doing", "Action 2") ; Perform Action 2 Else MsgBox(1, "Doing", "Action 1") ; Perform Action 1 EndIf EndIf Edited September 1, 2011 by czardas operator64 ArrayWorkshop 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