Jump to content

PixelSearch and MouseMove


Rawox
 Share

Recommended Posts

Hey,

I'm working on a script and I need to find a pixel(color) in a window. I already know that this can be done with PixelSearch and I already can find the color of the pixel.

The Only thing I want to have it done now is that it clicks on the pixel that it found.

Does anyone know what I mean and what I want? Please give me an example or a working script.

The color is: 0x46271C and the shades need to be set to: 10

Greetz, Rawox

Edited by Rawox
Link to comment
Share on other sites

Hey,

I'm working on a script and I need to find a pixel(color) in a window. I already know that this can be done with PixelSearch and I already can find the color of the pixel.

The Only thing I want to have it done now is that it clicks on the pixel that it found.

Does anyone know what I mean and what I want? Please give me an example or a working script.

The color is: 0x46271C and the shades need to be set to: 10

Greetz, Rawox

What about MouseClick?
Link to comment
Share on other sites

What about MouseClick?

Yes I know. But I want to do this...

Looks for pixel with the specified color or shades (max 10)
    - If exists then it needs to click on the pixel using MouseClick
    - If not exists it needs to search again but with a max number of 20 shades
                                                                      30 shades
                                                                      40 shades
                                                                            etc.
Link to comment
Share on other sites

This Is what I have...

; ============== COLOR FINDER ==============
; 1
$coord = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)

; ============== ONE ==============
If Not @error Then
    MouseClick ( "left", $coord[0], $coord[1] )
EndIf
If @error Then
    MsgBox ( 0, "Error", "Color Could not be Found..." )
EndIf

And this is what I want... But it isn't working properly, it clicks on the same place two times. not on a new place

; ============== COLOR FINDER ==============
; 1
$coord = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)
$coord1 = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)

; ============== ONE ==============
If Not @error Then
    MouseClick ( "left", $coord[0], $coord[1] )
    Sleep ( 3000 )
    MouseClick ( "left", $coord1[0], $coord1[1] )
EndIf
If @error Then
    MsgBox ( 0, "Error", "Color Could not be Found..." )
EndIf

Anyone?

Link to comment
Share on other sites

...

And this is what I want... But it isn't working properly, it clicks on the same place two times. not on a new place

....

Of course, you need read again if something changed in those 3 secs. $coord and $coord1 variables will be the same always with your code.

I'm not sure if you need a repetitive search after a click, because you can use a While loop in this case for check constantly.

Link to comment
Share on other sites

This Is what I have...

; ============== COLOR FINDER ==============
; 1
$coord = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)

; ============== ONE ==============
If Not @error Then
    MouseClick ( "left", $coord[0], $coord[1] )
EndIf
If @error Then
    MsgBox ( 0, "Error", "Color Could not be Found..." )
EndIf

And this is what I want... But it isn't working properly, it clicks on the same place two times. not on a new place

; ============== COLOR FINDER ==============
; 1
$coord = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)
$coord1 = PixelSearch( 400, 250, 650, 400, 0x46271C, 7)

; ============== ONE ==============
If Not @error Then
    MouseClick ( "left", $coord[0], $coord[1] )
    Sleep ( 3000 )
    MouseClick ( "left", $coord1[0], $coord1[1] )
EndIf
If @error Then
    MsgBox ( 0, "Error", "Color Could not be Found..." )
EndIf

Anyone?

Happy New Year...
Global $iColor = 0x46271C, $f_Found = False

For $iVariation = 10 To 40 Step 10
    $avCoord = PixelSearch(400, 250, 650, 400, $iColor, $iVariation)
    If @error = 0 Then
        MouseClick("left", $avCoord[0], $avCoord[1])
        Sleep(3000)
        MouseClick("left", $avCoord[0], $avCoord[1])
        $f_Found = True
        ExitLoop
    EndIf
Next

If $f_Found Then
    MsgBox(64, "Found", "Color " & $iColor & " found at " & $avCoord[0] & "\" & $avCoord[1])
Else
    MsgBox(16, "Not Found", "Color " & $iColor & " not found.")
EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...