Jump to content
Sign in to follow this  
doccy

Subscript used with non-Array variable

Recommended Posts

doccy

Hello guys, sorry if i bother you but i'm a total newbie in autoit scripting and i can't get rid off this error

My script try to find a color and if it find it to press the right mouse button on it.

Here it goes

HotKeySet("{HOME}","Clicker")

While 1

Sleep(1000)

WEnd

Func Clicker()

While 1

Opt("MouseClickDownDelay", 50)

Send("{SPACE}")

sleep(300)

$pos = PixelSearch (752,345,1001,589,0x3E0C3F)

sleep(2000)

If @error <> 1 then

MouseClick( "right" ,$pos[0], $pos[1])

EndIf

WEnd

EndFunc

I've tried everything if @error = 2 if not @error if @error = 0, but nothing helped ;)

Please help me :)

Share this post


Link to post
Share on other sites
qazwsx

try:

if _isarry ($pos) Then

and use code tags next time it makes it easier to read.

Share this post


Link to post
Share on other sites
Helge

Sleep sets @error to 0. You can at least solve this in three ways.

Storing @error in a variable :

$pos = PixelSearch (752,345,1001,589,0x3E0C3F)
$error = @error

Sleep(2000)

If $error <> 1 then
;If Ubound($pos) > 0 Then
;If IsArray($pos) Then
Edited by Helge

Share this post


Link to post
Share on other sites
doccy

i have tried it but it gives me an error like

if _isarray($pos) then

...

Error:Unknown function name.

Btw i used it instead of If @error <> 1 then, i hope i did it right :)

Share this post


Link to post
Share on other sites
doccy

Sleep sets @error to 0. You can at least solve this in three ways.

Storing @error in a variable :

$pos = PixelSearch (752,345,1001,589,0x3E0C3F)
$error = @error

Sleep(2000)

If $error <> 1 then
;If Ubound($pos) > 0 Then
;If IsArray($pos) Then
i didn't know sleep set @error to 0...

thanks i solved it !!

Share this post


Link to post
Share on other sites
weaponx

You shouldn't have been doing a sleep after PixelSearch anyways, it did nothing.

Share this post


Link to post
Share on other sites
narayanjr

its IsArray not _IsArray

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  

×