Jump to content

Recommended Posts

Posted

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

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
Posted

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

Posted

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

Posted

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

Posted

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

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
Posted

#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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...