Jump to content

SO frustrated! please help!


Recommended Posts

Been trying to work this out for hours now, and im so damn frustrated! The problem comes with the function pixelsearch, and the if not @error part. When pixelsearch detects that the color has been found through pixel search, it works just fine. (The mouse goes to the color and left clicks) When pixelsearch detects that the color has NOT been found, it should return @error.

However, when I run the script, AND COLOR IS NOT FOUND, it always returns this error:

MouseClick("left", $SR[0], $SR[1], 1,20)

MouseClick("left", $SR^ ERROR

Error: Subscript used with non-Array variable.

I just don't understand how $SR is not an array variable. I declared it with Dim $SR[2] in the beginning.

On top of that, it shouldnt even declare it as an error, since the color was not found in the first place, so it should not have went through the If not @error condition.

Wtf?? please help >.<

Code: Important parts bolded

AutoItSetOption ("SendKeyDownDelay", 150)

AutoItSetOption ("MouseClickDelay",0)

$x = 300

$y = 280

$xcounter = 0

$ycounter = 0

Dim $SR[2]

While 1

If $xcounter < 7 Then

$x = $x + 150

$xcounter = $xcounter + 1

Endif

If $xcounter = 7 Then

$xcounter = 0

$y = $y + 115

$ycounter = $ycounter + 1

EndIf

If $ycounter = 5 Then

$ycounter = 0

$xcounter = 0

$x = 450

$y = 280

MouseClick("left", 1302, 704, 1,20)

Endif

Sleep(5000)

MouseClick("left", $x, $y, 1,20)

Sleep(2000)

MouseClick("left", 238, 982, 1,20)

Sleep(2000)

MouseClick("left", 380, 986, 1,20)

SLeep(2000)

$SR = PixelSearch(0,0,660,1040,0xFFFF00,0,5)

SLeep(200)

If not @error Then

MouseClick("left", $SR[0], $SR[1], 1,20)

Endif

Sleep(7500)

MouseClick("left", 21, 55, 1,20)

Sleep(5000)

MouseClick("left", 21, 55, 1,20)

Wend

Func MyExit()

Exit

EndFunc

Edited by FrustratedProgramer
Link to comment
Share on other sites

It doesn't matter how you declared $SR... PixelSearch is overwriting it.

PixelSearch is failing, so $SR is no longer an array, it's the integer 1.

@error was set to 1, but Sleep set it back to zero before your comparison.

Either remove the sleep so your If statement can evaluate @error, or use IsArray instead.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

It doesn't matter how you declared $SR... PixelSearch is overwriting it.

PixelSearch is failing, so $SR is no longer an array, it's the integer 1.

@error was set to 1, but Sleep set it back to zero before your comparison.

Either remove the sleep so your If statement can evaluate @error, or use IsArray instead.

omg... thank you so much it actually fixed it...

So im confused, why does sleep set @error back to 0?

Link to comment
Share on other sites

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