Jump to content

pixel click


Recommended Posts

Here's what i am trying to do, search within a set amount of space for a specific pixel color. If/when pixel color exists, mousemove/click that pos. relative to the screen. Thanks in advance...

<{POST_SNAPBACK}>

That's exactly what I've been trying to do for weeks nows. I've been trying variations like this:

----------------------

; Get initial checksum

$checksum = PixelChecksum(150,155, 635,640)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load

; Find a pixel in the range

$coord = PixelSearch( 220, 222, 558, 600, 0x010101 )

While $coord = $checksum

MouseMove(65, 705, 0)

MouseClick("left")

Sleep(5000)

Wend

--------------------------

Currently it just clicks once and dies. I'm not sure if ckecksum can be used this way. I'm not sure if "While $coord = $checksum " is correct syntax either. I'd like to loop this, but one thing at a time I suppose. It has been 20 years since I programmed BASIC on the Apple IIe. While this is familiar / close ... it's no box of cigars.

suggestions would be helpful and appreciated.

TIA

Edited by mach42
Link to comment
Share on other sites

; Get initial checksum

$checksum = PixelChecksum(150,155, 635,640)

 

; Find a pixel in the range

$coord = PixelSearch( 220, 222, 558, 600, 0x010101 )

   

While $coord = $checksum

  MouseMove(65, 705, 0)

    MouseClick("left")

    Sleep(5000)

Wend

--------------------------

Currently it just clicks once and dies. I'm not sure if ckecksum can be used this way. I'm not sure if "While $coord = $checksum " is correct syntax either. I'd like to loop this, but one thing at a time I suppose. It has been 20 years since I programmed BASIC on the Apple IIe. While this is familiar / close ... it's no box of cigars.

<{POST_SNAPBACK}>

@mach42, @datkewlguy (similar)

PixelChecksum produces a unique value based upon the composition of the various pixel colors in a region.

PixelSearch locates the first pixel in a region of a specific color and returns an array if the color is found (or integer 1 otherwise).

As such, your while loop condition is never true, it does not click even once and the loop terminates without doing anything. You can prove this by adding a MsgBox within the while loop and see if the message box pops up.

I think you are looking for something like the following. While the specified color is found in the region searched, the loop continues and a left click is done every 5 seconds. When the color is no longer found, the while loop exits.

; Get the color to match (change this to suit).
$iColor = PixelGetColor(220, 222)

Dim $Coord[2]
While IsArray($Coord)
   $Coord = PixelSearch(220, 222, 558, 600, $iColor)
   If @error = 0 then
     ; The color was found
      MouseMove(65, 705, 0)
      MouseClick("left")
      Sleep(5000)
     ; A debug message that lasts only one second
      MsgBox(4096, "Debug", "Mouse Left Click done.", 1)
   EndIf
WEnd
MsgBox(4096, "Debug", "While loop has terminated")

Phillip

Link to comment
Share on other sites

The problem for me really is just finding the x and y coords of where the pixelsearched pixel was found... anyone know how to do that?

i dont want it to click a certain position, i want it to click where the pixel was found...

Edited by datkewlguy
Link to comment
Share on other sites

Guest h1pp0

The problem for me really is just finding the x and y coords of where the pixelsearched pixel was found... anyone know how to do that?

i dont want it to click a certain position, i want it to click where the pixel was found...

<{POST_SNAPBACK}>

PixelSearch returns the x and y coords of the pixel. From the doc: (hxxp://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm)

Success:  Returns a two-element array of pixel's coordinates. (Array[0]= x, Array[1] = y)

Something like this might work

$coords = PixelSearch (left, top, right, bottom, color)
MouseClick ("left",$coords[0], $coords[1])

BTW, I've just started using this program so take this advice with a grain of salt =P

Link to comment
Share on other sites

phillip123adams

... your while loop condition is never true, it does not click

even once and the loop terminates without doing anything.

You can prove this by adding a MsgBox within the while loop

and see if the message box pops up.

(yup)[/color=red]

I think you are looking for something like the following. While

the specified color is found in the region searched, the loop

continues and a left click is done every 5 seconds. When the color

is no longer found, the while loop exits.

; Get the color to match (change this to suit).
$iColor = PixelGetColor(220, 222)

Dim $Coord[2]
While IsArray($Coord)
   $Coord = PixelSearch(220, 222, 558, 600, $iColor)
   If @error = 0 then
    ; The color was found
      MouseMove(65, 705, 0)
      MouseClick("left")
      Sleep(5000)
    ; A debug message that lasts only one second
      MsgBox(4096, "Debug", "Mouse Left Click done.", 1)
   EndIf
WEnd
MsgBox(4096, "Debug", "While loop has terminated")

That was helpful and thanks!

I think some variations I've been trying never had

the @error properly set and the nested statements were

wacky. Further reading in the forum has it working

(I think) complete with an escape / pause.

Thanks again!

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