demonachize Posted January 8, 2011 Share Posted January 8, 2011 I have a need to look for a pixel color in one place while it doesn't exist in two other places. I am trying to use: While PixelGetColor(1579, 546) = 0xFFDE4B and not PixelGetColor(1820, 735) = 0xFFDE4B or not PixelGetColor(1819, 767) = 0xFFDE4B MouseCLick ( "primary", 1579, 546, 1, 1) WEnd This is clearly not working and I am confused as to how to join multiple statements using operators. The end result would be that I want to ensure that a certain button is pushed that stays visible in the background while a new window in the foreground pops up and then another pops up after that. I know of a different way to approach it that I will probably use but I still would like to know how to do it this way for my own knowledge. Link to comment Share on other sites More sharing options...
JohnOne Posted January 8, 2011 Share Posted January 8, 2011 (edited) I'd probably do something like this. While PixelGetColor(1579, 546) = 0xFFDE4B If PixelGetColor(1820, 735) <> 0xFFDE4B And PixelGetColor(1819, 767) <> 0xFFDE4B Then MouseCLick ( "primary", 1579, 546, 1, 1) EndIf WEnd Edited January 8, 2011 by JohnOne 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...
Moderators Melba23 Posted January 8, 2011 Moderators Share Posted January 8, 2011 (edited) demonachize,When you use multiple logical operators you need to be very careful - especially if you use any Not operators in there as well. Top Tip 1: Do not use multiple logical operators - split your line into 2:While PixelGetColor(1579, 546) = 0xFFDE4B If PixelGetColor(1820, 735) <> 0xFFDE4B Or PixelGetColor(1819, 767) <> 0xFFDE4B Then MouseCLick ( "primary", 1579, 546, 1, 1) EndIf WEndTop Tip 2: If you want to keep it on one line, then use parentheses to carefully delineate the separate sections and to define the scope of the Not operator. Look at this small test script which replicates your basic logic:expandcollapse popup; True, True, True -> True And (Not(True) Or Not(True)) ; -> True And (False Or False) ; -> True And False ; -> False ; -> Exit Loop ; True, False, True -> True And (Not(False) Or Not(True)) ; -> True And (True Or False) ; -> True And True ; -> True ; -> Stay in loop ; True, True, False -> True And (Not(True) Or Not(False)) ; -> True And (False Or True) ; -> True And True ; -> True ; -> Stay in loop ; True, False, False -> True And (Not(False) Or Not(False)) ; -> True And (True Or True) ; -> True And True ; -> True ; -> Stay in loop ; False, Any, Any -> False And (Not even evaluated) ; -> False ; -> Stay in loop ; -> Exit Loop $fWanted = True $fUnwanted_1 = True $fUnwanted_2 = False $iBegin = TimerInit() While $fWanted And (Not($fUnwanted_1) Or Not($fUnwanted_2)) If TimerDiff($iBegin) > 100 Then ConsoleWrite("Still In Here!" & @CRLF) Exit EndIf Sleep(10) WEnd ConsoleWrite("Out!" & @CRLF)See how I have set the parentheses to limit the scope of the 2 Not operators and also to make sure the Or pair are always evaluated together. By changing the values of the 3 variables you can see how the While line reacts.So I would suggest going with this for your script:While (PixelGetColor(1579, 546) = 0xFFDE4B) And (Not (PixelGetColor(1820, 735) = 0xFFDE4B) Or Not ( PixelGetColor(1819, 767) = 0xFFDE4B)) MouseCLick ( "primary", 1579, 546, 1, 1) WEndAnd you might want to add a Sleep(10) as well to keep the CPU cool in a tight loop like that. M23Edit: Wrong button, too soon! Edited January 8, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
demonachize Posted January 8, 2011 Author Share Posted January 8, 2011 Thanks to both of you. This makes perfect sense now. I appreciate that you took the time to give me those pointers. 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