Lazzo Posted September 17, 2010 Share Posted September 17, 2010 okay so as you can imagine I'm a total noob here, just started learning, so for my first project I tried to make a simple mouse clicker but it doesnt seem to work =/ Func BotStart() $pt = PixelSearch (625, 405, 1284, 942, 0xD2D2D2) sleep(500) if Not @error Then mouseclick( "left", $pt[0], $pt[1], 1, 0) Sleep (500) $coord1 = PixelSearch (638, 349, 1299, 790, 0xFF0000) Sleep (1000) MouseClick ( "left", $coord1[0], $coord1[1], 1, 0) Sleep (650000) MouseClick ( "left", 485, 132, 1, 0) Sleep (1000) Else Sleep(55000) Return EndIf EndFunc While 1 MouseClick ( "left", 853, 230, 1, 0) Sleep (3000) Call("BotStart") Wend so, it clicks on 853,230 and start the botstart function where it searches for a color in the box and if it finds the color it does aditional clicks, if it does not find the color it sleeps then starts again but my problem is that if it does not find the color it does not sleep but gives me an error at mouseclick( "left", $pt[0], $pt[1], 1, 0) saying subscript used with non-Array variable I understand its because the pixelsearch did not return any coordinates but why did it not jump to the else statement? :S I even tried with if IsArray($pt) then.... else... but I get the same error lol I'm really stuck atm :S Link to comment Share on other sites More sharing options...
water Posted September 17, 2010 Share Posted September 17, 2010 Two things to consider:it does not sleepSleep(500) only sleeps half a second. So you won't notice the delay.if it does not find the colorIn your code you check @error after the Sleep command - so you check the @error code of Sleep. Move the Sleep after the error checking. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Lazzo Posted September 17, 2010 Author Share Posted September 17, 2010 (edited) Two things to consider:Sleep(500) only sleeps half a second. So you won't notice the delay.In your code you check @error after the Sleep command - so you check the @error code of Sleep. Move the Sleep after the error checking.oh damn, didnt realize it checks @error for sleep then, how silly am I Thanks a lot! Edited September 17, 2010 by Lazzo Link to comment Share on other sites More sharing options...
water Posted September 17, 2010 Share Posted September 17, 2010 It works fine for me. I get "Not found" written to the SciTE console. Botstart() Func BotStart() $pt = PixelSearch(625, 405, 1284, 942, 0xD2D2D2) If Not @error Then ConsoleWrite("Found" & @CRLF) Sleep(500) MouseClick("left", $pt[0], $pt[1], 1, 0) Sleep(1000) $coord1 = PixelSearch(638, 349, 1299, 790, 0xFF0000) Sleep(1000) MouseClick("left", $coord1[0], $coord1[1], 1, 0) Sleep(650000) MouseClick("left", 485, 132, 1, 0) Sleep(1000) Else ConsoleWrite("Not found" & @CRLF) Sleep(55000) Return EndIf EndFunc ;==>BotStart My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JohnOne Posted September 17, 2010 Share Posted September 17, 2010 You are using an awful high sleep count time for just learning - 650000? long time to wait that try if Not @error And $pt[0] Then AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted September 17, 2010 Share Posted September 17, 2010 What are you trying to achieve with your script? The function name sounds a bit suspicious. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Lazzo Posted September 17, 2010 Author Share Posted September 17, 2010 yeah it works, I started the wrong script earlyer lol this one just clicks links gona try some window popups next 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