Elevenster_Loading Posted January 17, 2020 Share Posted January 17, 2020 Hello friends ; ) ! I hope this is the right forum to use Technically i'm new to AutoIT, so i'm always using the example found in the Help file for my functions For the PixelSearch function, it's something like this .. Local $aCoord = PixelSearch(x , y , x , y , 0xFF0000) If Not @error Then MsgBox(0,"Found it", "Pure red") EndIf What i want to do is put multiple pixelsearchs in If, ElseIf etc ..... EndIf condition .. i tried few stuff like If Pixelsearch (x,y,x,y,0x000000) = True Then ; Code End If but it never worked .. i tried this too .. If PixelSearch (x,y,x,y,0x00000) = Not @Error Then ;code EndIf same thing .. My ideal code would be If PixelSearch_1 Then ............ ElseIf PixelSearch_2 Then ............ ElseIf PixelSearch_3 Then ............ ElseIf PixelSearch_4 Then ........... EndIf but i don't know how to write the code properly for it to work, i hope one of you could guide me in this & Thanks in advance. Link to comment Share on other sites More sharing options...
Nine Posted January 17, 2020 Share Posted January 17, 2020 Something like this : Local $x = 100, $y = 100 Local $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0xFF0000) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Red found at " & $aCoord[0] & "/" & $aCoord[1]) Else $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0x00FF00) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Green found at " & $aCoord[0] & "/" & $aCoord[1]) Else $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0x0000FF) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Blue found at " & $aCoord[0] & "/" & $aCoord[1]) Else MsgBox ($MB_SYSTEMMODAL,"","No color found") EndIf EndIf EndIf If you only want to search for a single pixel, use PixelGetColor () instead... Elevenster_Loading 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted January 17, 2020 Share Posted January 17, 2020 If you got multiple colors to search, you could also make it in a loop (with a Const $array) instead of using embedded IF. Would make it more compact and readable. Elevenster_Loading 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Elevenster_Loading Posted January 17, 2020 Author Share Posted January 17, 2020 I used to use .. PixelSearch(100,200,100,200,0x00000) to look for a single pixel, meanwhile i could have used PixelGetColor() all along Damn ... thank you so much, that's exactly what i needed Now, i figured out how to do it ! While 1 Local $Color = PixelGetColor (x,y) If $Color = 0 Then MsgBox (0, "The color is","Black") ElseIf $Color = 255 Then MsgBox (0, "The color is","Blue") ElseIf $Color = 16711680 Then MsgBox (0, "The color is","Red") EndIf ;All colors must be written in decimal form Link to comment Share on other sites More sharing options...
Elevenster_Loading Posted January 17, 2020 Author Share Posted January 17, 2020 9 minutes ago, Nine said: If you got multiple colors to search, you could also make it in a loop (with a Const $array) instead of using embedded IF. Would make it more compact and readable. Oh, naa not really, only got few colors to deal with But if i stumble into a multi color problem, i'd definitely try a Const $array Link to comment Share on other sites More sharing options...
Nine Posted January 17, 2020 Share Posted January 17, 2020 7 minutes ago, Elevenster_Loading said: ;All colors must be written in decimal form No you can use this notation : If $color = 0xFF0000 Then I personally prefer using hex format... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Elevenster_Loading Posted January 17, 2020 Author Share Posted January 17, 2020 Trueeeeeeeee ! it worked also, that's nice I prefer Hex too. Nine 1 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