Sign in to follow this  
Followers 0
muzle6074

Help with moving to detected colors!

9 posts in this topic

$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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thankyou Bert! :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0