ends Posted May 8, 2007 Share Posted May 8, 2007 Hello I'm new to AutoIt. I've been messing around with it for awhile now and have made several scripts that have been very useful to me. But i can't seem to get this one to work. I want it to find a button that appears in differant areas on the screen and click it. With this one it's giving me an error of Subscript used with non-Array variable. Which i have no idea what that means. I've done many searches on the forums and can't find anything that helps me or maybe i have found something but don't understand it. expandcollapse popupHotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") Sleep(15000); $i=0; Do destroy() Until $i=1000000; Func destroy() Send("{i}"); sleep(2000); MouseMove(648,660, 2); Sleep(500); MouseClick("right", 648, 660, 1); Sleep(1000); $coord = PixelSearch( 655, 738, 631, 729, 14281964); MouseMove($coord[0],$coord[1]); sleep(500); MouseClick("left",$coord[0],$coord[1]); sleep(1000) Send("{i}"); sleep(2000) EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc please help.... Link to comment Share on other sites More sharing options...
tAKTelapis Posted May 8, 2007 Share Posted May 8, 2007 (edited) Well, try this didnt modify much i changed your Do loop into a For loop (nothing wrong with how it was, but i think for looks nicer ) and most importantly, added an error check onto your pixel search.. near as i can tell, the reason that $coord[0] and $coord[1] were showing as errors is because the pixel search was failing. otherwise it should work (i have NO idea what you are pixel searching for, but my computer does not have it on the desktop.) expandcollapse popupGlobal $Paused ; added paused as a global as it reigstered as being used without being delcared HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") Sleep(15000); For $i = 1 to 1000000 step 1 destroy() Next Func destroy() Send("{i}"); sleep(2000); MouseMove(648,660, 2); Sleep(500); MouseClick("right", 648, 660, 1); Sleep(1000); $coord = PixelSearch( 655, 738, 631, 729, 14281964); ;added error check if @error = 1 Then MsgBox(0, "test", "Pixel search failed") Exit EndIf ; end of error check MouseMove($coord[0],$coord[1]); sleep(500); MouseClick("left",$coord[0],$coord[1]); sleep(1000) Send("{i}"); sleep(2000) EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit EndFunc Edited May 8, 2007 by tAKTelapis Link to comment Share on other sites More sharing options...
xcal Posted May 8, 2007 Share Posted May 8, 2007 (edited) You could also pause that $coord part of your script until it's an array, like... While 1 $coord = PixelSearch( 655, 738, 631, 729, 14281964) If IsArray($coord) Then ExitLoop Sleep(100) Wend edit - Looks like your pause doesn't do anything? Might want to change your loop to something like... Do If Not $Paused Then destroy() Until $i=1000000; Edited May 8, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
tAKTelapis Posted May 8, 2007 Share Posted May 8, 2007 Yeah, it appears to me that his Pause is out of whack. I never studied that, i was looking more at the array issue. Link to comment Share on other sites More sharing options...
ends Posted May 8, 2007 Author Share Posted May 8, 2007 Thank you very much for your help. It seems the pixel search failed. I'm using this inside a game to delete an in game item. Right click to use radial menu on the item then find the destroy option to delete it. Why would the pixel search fail? could it be cause there are other matches or no matches at all? And yea i really don't use the pause at all cause it doesn't seem to work. Link to comment Share on other sites More sharing options...
ends Posted May 8, 2007 Author Share Posted May 8, 2007 ok i think i got it... guess i too didn't understand the cords for Pixelsearch until i read the post "Question for Pixelsearch, Coordinates". It's selecting the wrong button but i think if i mess around with it i bit i should be able to get it. Thank you all for your help. 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