FrustratedProgramer Posted June 5, 2009 Share Posted June 5, 2009 (edited) 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^ ERRORError: 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 boldedAutoItSetOption ("SendKeyDownDelay", 150)AutoItSetOption ("MouseClickDelay",0) $x = 300$y = 280$xcounter = 0$ycounter = 0Dim $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) WendFunc MyExit()ExitEndFunc Edited June 5, 2009 by FrustratedProgramer Link to comment Share on other sites More sharing options...
Skruge Posted June 5, 2009 Share Posted June 5, 2009 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 More sharing options...
FrustratedProgramer Posted June 5, 2009 Author Share Posted June 5, 2009 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 More sharing options...
KaFu Posted June 5, 2009 Share Posted June 5, 2009 So im confused, why does sleep set @error back to 0?Because sleep() is a function too, and as far as I know any function resets @error, even if it does not have a return value. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21)HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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