Jump to content

Please help- just starting out


Recommended Posts

I have used autoit for a short time just messing around and seeing what is possible, and wondering how i could make autoit search for a particular color, then just cause the cursor to click on it. I have looked online and seen:

PixelSearch ()- but the parameters never work out for me.

So if anyone could just help me out with searching for a color and clicking on it and i would really appreciate it.

Thank you

Link to comment
Share on other sites

I have used autoit for a short time just messing around and seeing what is possible, and wondering how i could make autoit search for a particular color, then just cause the cursor to click on it. I have looked online and seen:

PixelSearch ()- but the parameters never work out for me.

So if anyone could just help me out with searching for a color and clicking on it and i would really appreciate it.

Thank you

<{POST_SNAPBACK}>

Hi look on your Autoit3 Install folder for the exampel folder and serach for the pixelsearch exampel! :lmao:

good look! o:)

Link to comment
Share on other sites

well i have no idea what to use, so i just put the hexidecimal code in as a guess, but that was an error, and the couple i have seen have it set up with multiple numbers.

So i don't know how to make it search for a certain pixel color.

btw dirty- i cant find it... :lmao:

Edited by pedmaster
Link to comment
Share on other sites

Here's a quick example, this will search in the area of my recycle bin and double-click the first green pixel it finds:

$coord = PixelSearch( 953, 656, 1011, 711, 0x019901 )
MouseClick( "left", $coord[0], $coord[1], 2 )

I get the coordinates of the pixel it finds collected into $coord[0] (x) and $coord[1] (y) (it adds the [0] and [1] automatically), then use those found coordinates in the MouseClick function to tell it where to click. Does that make any sense?

Link to comment
Share on other sites

Yes, but where does '( 953, 656, 1011, 711, 0x019901 )'

come from?

953 is to the left of my recycle bin, 656 is above it, 1011 to the right of it, and 711 below it. These are the coordinates that define the area I want to be searched. The 0x019901 is the hex for the color I wanted it to search for.

Sleep (2000)

$icolor = 0xDF7419

$coord = PixelSearch ( 825, 155, 841, 171, $icolor )

Sleep (1000)

MouseClick( "right", $coord, $coord, 1

I haven't tried this code yet, but right now I can mention that you don't need the [0] or [1] for $coord = PixelSearch, but you DO need it in the coordinates: MouseClick( "right", $coord[0], $coord[1] ). (my apologies for the miscommunication)

I changed it to this:

Sleep (2000)
$icolor = 0xDF7419
$coord = PixelSearch ( 825, 155, 841, 171, $icolor )
Sleep (1000)
MouseClick( "right", $coord[0], $coord[1] )
and it gave me an error only because it didn't find that color (orange?) within that range (it's off my screen, my resolution isn't that hight :lmao: ) But try that code and see if it works. Edited by falconv
Link to comment
Share on other sites

Yes, thanks again, i have figured out how to get it working.

What i can't figure out now is how to make it retry the sequence and search again after there is an error, say it didnt find the pixel.

It just brings up the error msg, but I don't want it to, I am hoping to make it retry the pixel search.

$Repeat = 0
$icolor = 0xDF7419
While $Repeat <= 10
Sleep (2000)
$coord = PixelSearch ( 825, 155, 841, 171, $icolor )
Sleep (1000)
MouseClick( "right", $coord[0], $coord[1], 1 )
Sleep (3000)
WEnd
Edited by pedmaster
Link to comment
Share on other sites

$Repeat = 0
$icolor = 0xDF7419
While $Repeat <= 10
   Sleep (2000)
   $coord = PixelSearch ( 825, 155, 841, 171, $icolor )
   If NOT @error Then
      Sleep (1000)
      MouseClick( "right", $coord[0], $coord[1], 1 )
      Sleep (3000)
   EndIf
WEnd

Good luck.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...