Jump to content

Help with moving to detected colors!


Recommended Posts

$j = 543824
$w = "i"
WinWaitActive($w)
WinMove($w, "", 0, 0)
While 1
    Sleep(10)
    $c = PixelSearch(0, 0, 800, 600, Hex($j, 6))
WEnd

If the pixelsearch is successful I want to be able to move the mouse to where this pixel value is located. How can I do that using mouse move?

Link to comment
Share on other sites

$j = 543824
$w = "i"
WinWaitActive($w)
WinMove($w, "", 0, 0)
While 1
    Sleep(10)
    $c = PixelSearch(0, 0, 800, 600, Hex($j, 6))
WEnd

If the pixelsearch is successful I want to be able to move the mouse to where this pixel value is located. How can I do that using mouse move?

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

MouseMove ($array[0], $array[1])

And RTFM. That took me 2 seconds in the helpfile. 1 to look for PixelSearch return values, and the other to see the syntax for MouseMove.

Edited by Bert
Link to comment
Share on other sites

Thanks for quick response Bert.

I was aware of the returning values but I don't know how to declare an array that stores the returning values of a PixelSearch(). I'm new to AutoIt please help :D

$array = PixelSearch ()

$x = $array[0]

I'm sure you can work out the rest

Link to comment
Share on other sites

While 1
    Sleep(10)
    $array = PixelSearch(0, 0, 800, 600, Hex($javelin, 6))
    $x = $array[0]
    $y = $array[1]
    MouseMove($x, $y)
WEnd

Says "Error: Subscript used with non-Array varaible."

Please dont laugh @ me :D

What does it return if there is an error? Hmmm? That and conditional statements. I'm not going to do all the work for u.
Link to comment
Share on other sites

Ok, I came up with this. It didnt throw an error but it didnt work either :D

#include <Array.au3>
$j = "543824"
$w = "i"
WinWaitActive($w)
WinMove($w, "", 0, 0)
While 1
    Sleep(10)
    $coords = PixelSearch(0, 0, 800, 600, Hex($j, 6))
    if Not @error Then
        $x = $coords[0]
        $y = $coords[1]
        MouseMove($x, $y)
    EndIf
WEnd
Link to comment
Share on other sites

#include <Array.au3>

$j = "FFFFFF"

$w = "i"

;WinWaitActive($w)

;WinMove($w, "", 0, 0)

While 1

Sleep(10)

$coords = PixelSearch(0, 0, 800, 600, "0x" & $j, 20)

ConsoleWrite (@error & @CRLF)

if Not @error Then

$x = $coords[0]

$y = $coords[1]

MouseMove($x, $y)

EndIf

WEnd

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