Sign in to follow this  
Followers 0
autoit21

PixelSearch issue/question

2 posts in this topic

#1 ·  Posted (edited)

The documentation says that PixelSearch searches from top to bottom, left to right, which does it do first the top to bottom or left to right? From the looks of it's left to right frist. If I have 2 obects that I know are the same, one being up higher on the screen and the second one being lower but left of the higher one PixelSearch finds the lower left one first.

My second question/consern is if I have the same situation as stated in the above example and I want to search for both not just the first one I can't seem to get it find the one that is above and to the right of the first one it finds.

Here is a sample of my code:

;search for the pixel coloe and move mouse to it
  $coord = PixelSearch (150, 100, 890, 500, 0x893212, 35,2)
If Not @error Then
    MouseMove($coord[0], $coord[1])
  $pos = MouseGetPos()
EndIf
;This part does a check to see if the mouse changes
$coord = PixelSearch ($Pos[0] - 10, $pos[1] - 10, $pos[0] + 10, $pos[1] + 10, 0xDAAC62, 30, 2) 
   If @error Then
 $coord = PixelSearch ($pos[0] + 20, 100, 890, 500, 0x893212, 35,2)
     If Not @error Then
       MouseMove($coord[0], $coord[1])
         $pos = MouseGetPos()
   EndIf
EndIf

The second search ($coord = PixelSearch ($Pos[0] - 10, $pos[1] - 10, $pos[0] + 10, $pos[1] + 10, ) does a search around the area where the mouse is moved to to see if the mouse pointer has changed, if it didn't change then it is suppose to search again but reducing the search box by moving the left edge in 20 pixels. I am trying to get this to loop until if finds the one spot at which my mouse pointer changes.

If I have icons setup like this

.....X1

X2

..............X3

........X4

The code never seems to be able to find X1 nor X3, but it has no problem finding X2 first and then X4 second. If the search was indead left to right, top to bottom then you would think it would find X2, X1 X4 then X3. Any thoughts or ideas?

Edited by autoit21

Share this post


Link to post
Share on other sites



this is a little search that points to my colored folders on the desktop. I chose a yellow.

HotKeySet("{pause}","pause")

for $y=0 to 1200 step 100
   for $x=0 to 1200 step 100
      $loc=PixelSearch($x,$y,$x+100,$y+100,16777116,2,4)
      if UBound($loc)=2 then
         MouseMove($loc[0],$loc[1],1)
         sleep(1000)
      EndIf
      tooltip($x &" - " &$y,0,0)
   Next
Next

func pause()
   Exit
EndFunc  ;==>pause

just pauses mouse on each one, hit pause if something goes wrong.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0