Xaariel Posted February 14, 2018 Share Posted February 14, 2018 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 Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 Use IsArray to test the value of $Res before issuing the mouse click. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Imp Posted February 14, 2018 Share Posted February 14, 2018 Maybe FFNearestPixel() return not array Link to comment Share on other sites More sharing options...
Xaariel Posted February 14, 2018 Author Share Posted February 14, 2018 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 Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 When should the Do Loop exit? Right now, it appears to only exit after the 35th consecutive failed attempt. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Xaariel Posted February 14, 2018 Author Share Posted February 14, 2018 Yeah, I want the mouse to click right after 35th fail Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 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> Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Xaariel Posted February 14, 2018 Author Share Posted February 14, 2018 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 Link to comment Share on other sites More sharing options...
Danp2 Posted February 14, 2018 Share Posted February 14, 2018 @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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now