Jump to content
Sign in to follow this  
Xaariel

non accessible variable

Recommended Posts

Xaariel

Hi!
I am stuck already 2 hours with this problem. I feel like I tried every way I could think of. I searched the forum, still cant solve it.
I assume its problem with pixelsearch in Do,Until and mouseclick out of it.
 

Do
$Res = FFNearestPixel(850, 450, -1)
   If @error Then
$kk = $kk + 1
sleep(25)
ElseIf not @error Then
   $kk = 0
EndIf
Until $kk = 35
Mouseclick("right", $Res[0], $Res[1],1,2)

Mouseclick("right", $Res[0], $Res[1],1,2)
Mouseclick("right", $Res^ ERROR

error: Subscript used on non-accessible variable.

Will be really grateful if anyone can help me fix this

Share this post


Link to post
Share on other sites
Imp

Maybe FFNearestPixel() return not array

Share this post


Link to post
Share on other sites
Xaariel

Well,
 

$Res = FFNearestPixel(850, 450, 0x98A622)
If Not @Error Then MsgBox (0, "Resource", "Found in" & $Res[0] & "," & $Res[1])

seems to work perfectly, so it does, I am just too stupid to see a mistake

Share this post


Link to post
Share on other sites
Xaariel

Yeah, I want the mouse to click right after 35th fail

Share this post


Link to post
Share on other sites
Danp2

But the contents of $Res are presumably invalid after a failed call to FFNearestPixel. Maybe you should switch this up to strore the result to a temporary variable and then save that value to $Res whenever an error hasn't occurred. <shrug>

Share this post


Link to post
Share on other sites
Xaariel

Something like this?

Do
      sleep(50)
$Res = FFNearestPixel(850, 450, 0x46331C)
If not @error Then
   $kk = 0
   $Res[0] = $x12
   $Res[1] = $y12
Else
   $kk = $kk+1
   EndIf
Until $kk = 30
MsgBox (0, "Resource", "Found in" & $x12 & "," & $y12)

Now array has always 0

 

Share this post


Link to post
Share on other sites
Danp2

@Xaariel You post an incomplete snippet of code and expect us to solve whatever issues you are encountering. Does that make sense to you?

What would you expect it to contain? Why are you storing the result of FFNearestPixel to $Res and then replacing that with $x12 / $y12? Where are these variables defined? When do they get assigned a value? When does that value change?

I would suggest that you post a complete example that we can run if you want us to provide further input. Also, tell us what application you are trying to automate because there is often a better option than performing a pixel search.

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  

×