Jump to content
Sign in to follow this  
lysander

Error wirh pixel search

Recommended Posts

lysander

Hi

Im trying to make this:

HotKeySet("{NUMPAD7}", "vida")
HotKeySet("{NUMPAD2}","lTGetCoord") ;left top x, y
HotKeySet("{NUMPAD3}","rBGetCoord") ; right bottom x, y

While 1
        Sleep(100)
WEnd

func vida()
$location = PixelSearch ( $posLT[0], $posLT[1], $posBR[0], $posBR[1], 0x000000)
If IsArray ($location) = 1 Then 
    MouseClick ('left', $location[0], $location[1], 1, 0) 
    sleep(100)
    MouseClick ('left', $location[0], $location[1], 1, 0) 
EndIf
EndFunc

Func rBGetCoord()
    $posRB = MouseGetPos()
EndFunc

Func lTGetCoord()
    $posLT = MouseGetPos()
EndFunc

Then, i run the app, i push numpad2 and numpad 3 BUT when i push numpad 7 to run the func vida (with the pixelsearch) i have this error:

$location = PixelSearch ( $posLT[0], $posLT[1], $posRB[0], $posRB[1], 0x000000)
$location = PixelSearch ( ^ ERROR

and the program ends

I dont understand, without vars in pixelsearch it works, but i need that the user can change the area.

Edited by lysander

Share this post


Link to post
Share on other sites
kaotkbliss

your $posLT and $posBR are Local so when the function ends, the variables are cleared. Declare them as Global at the top of the script.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.