Jump to content

Clicking a Certain Color Pixel


Guest Keelan
 Share

Recommended Posts

Hello Everyone! I just downloaded AutoIt today and I love it and I want to thank the devs for making such a great program. Now, to my problem. I looked through commands like Pixel Search but I can't find a way to make my mouse click a pixel that's a crtain color. Does anyone know how to do this? Thank you! :lmao:

Link to comment
Share on other sites

Straight from the help file... (Most of it at least :lmao:)

; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If Not @error Then
    MouseClick ("left", $coord[0], $coord[1])
EndIf

that should work...

FootbaG
Link to comment
Share on other sites

PixelSearch is input as a rectangular box that you draw on the screen for it to search in.

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )

can be a little confusing, so we'll put in in algebraic terms.

x1,y1
+---------------------+
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
+---------------------+
                      x2,y2

PixelSearch(x1,y1,x2,y2,colour,shade-variant,step)

Colour is required, and is in decimal or hex. Use hex though it's easier. Note as 0xRRGGBB in hexidecimal format. so, pure red is 0xff0000.

The shade variant is the ammount that the pixel can vary from the specified colour. It's an optional parameter and if not supplied, we're only looking for an exact colour match.

The step is how many pixels to search. Step 1 will search every pixel in the box, step 2 will search every other pixel, step 3 will search 1/3 of the pixels, etc. As with the shade variant, this is also an optinal parameter and defaults to 1.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Thanks Drache I understand it now. :lmao: How do I make it repeat the action an infinite amount of times?

Edited by Keelan
Link to comment
Share on other sites

HotKeySet ("^e", "MyExit")
While 1
; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If Not @error Then
    MouseClick ("left", $coord[0], $coord[1])
EndIf
WEnd
Func MyExit ()
Exit
EndFunc

press Ctrl+E to exit... you should look in the help file :lmao:

[/

FootbaG
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...