Dgameman1 10 Posted October 2, 2011 How can I make it keep clicking a color until it no longer appears? I've tried this but it doesn't work $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) If Not @error Then Do MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) Until @error EndIf sleep(100) It doesn't work Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 Where are you checking if the color changed in the DO...Until loop? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 I'm checking to see if the color changed with the until @error Share this post Link to post Share on other sites
water 2,387 Posted October 2, 2011 @error is set by Pixelsearch. So you have to call Pixelsearch in the loop and then check @error. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 I'm checking to see if the color changed with the until @errorNo you are not. You perform the PixelSearch() only one time initially and then go into the loop. In the Loop you only test the Error value returned by MouseClick(). Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 Ohh I see, so the correct way would be to write it as... $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) If Not @error Then Do $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) Until @error EndIf sleep(100) ??? Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 No try to think this through before posting! You still test the @error returned by MouseClick(). SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 No try to think this through before posting! You still test the @error returned by MouseClick(). I've been trying but I really have no idea. I barely even know how to use @error and when i look in the helpfile it sends me to seterror which confuses me =/ Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 I've been trying but I really have no idea. I barely even know how to use @error and when i look in the helpfile it sends me to seterror which confuses me =/Then I would advice you to start learning the language first before writing your 2000 lines scripts 1 Dgameman1 reacted to this SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 Then I would advice you to start learning the language first before writing your 2000 lines scripts =PAs of now it's 2,666 =PSo, where can I actually understand what @error does?Could you give me an example? Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 Helpfile? @Error contains the Error of the last performed Function. Nothing more or Less. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 Hmm... So is it this? $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) If Not @error Then Do $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) Until @error EndIf sleep(100) So what that does is... it looks for $coord75, if it finds it then, it looks for $coord75 again, if it finds it then it clicks it, then it looks for it again and if its not an error then it does that again, but if it is an error then it finishes? Share this post Link to post Share on other sites
water 2,387 Posted October 2, 2011 Test your code and see if you get the desired results. 1 Dgameman1 reacted to this My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 (edited) Test your code and see if you get the desired results. I ran it, and it kept clicking them until it couldnt find the color anymore, but when it couldnt find the color, it gave me an error C:\Users\Dgameman1\Desktop\Code\AutoIt\lulz.au3 (2396) : ==> Subscript used with non-Array variable.: MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) MouseClick("left",$coord75^ ERROR Edited October 2, 2011 by Dgameman1 Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 Listen my friend, There is no way you have written a working 2000+ script when asking questions like this... Now, go and follow the available tutorial and do some actual work before coming back here. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 (edited) Listen my friend, There is no way you have written a working 2000+ script when asking questions like this... Now, go and follow the available tutorial and do some actual work before coming back here. Jos That wasn't very nice. And my code does work. The reason it works is because it doesn't need anything more than, wait for this color to appear, click it. And that's all the script does. And if I ever do get stuck on something, I try and figure it out myself, and it's worked so far, but when I don't understand something I look in the helpfile and the helpfile always tells me. But i looked for @error in the helpfile and it sent me to seterror, i looked in the example script, because that is how I learn, and it didn't even use the words @error anywhere. And I did try my best. I know it wasn't very good, but I did. and I still can't figure it out. And I understand that the theme with autoit forums is to give hints and figure it out yourself, but I really can't figure it out =// I started out with $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) If Not @error Then Do MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) Until @error EndIf sleep(100) And from your helped I learned I need to put the actual pixelsearch inside so I did. But that still didn't work. I then tested it out myself by adding in another pixelsearch and it worked until it didn't find that color, and now I post the error and I do not understand what it means. So instead of telling me I have failed, which i am fully aware, I ask you to help me understand what the error code means. Edited October 2, 2011 by Dgameman1 Share this post Link to post Share on other sites
Jos 2,209 Posted October 2, 2011 So instead of telling me I have failed, which i am fully aware, I ask you to help me understand what the error code means.Don't recall telling you you have failed, only that you need to learn more about the basics before continuing.So be it when the truth hurts, but it remains a fact you need to learn some basic first. Enjoy the studying ... over and out.Jos 1 Dgameman1 reacted to this SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 (edited) Ok, I think i figured it out. If I haven't I'm just going to go cry lol Is this it? $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) If Not @error Then Do $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) MouseClick("left",$coord75[0] + 15, $coord75[1] + 5, 1 , 0) $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) sleep(200) Until not isArray($coord75) EndIf sleep(100) Edited October 2, 2011 by Dgameman1 Share this post Link to post Share on other sites
Unsigned 5 Posted October 2, 2011 (edited) This is what you want. Explanation is in the comments since you seem to learn better that way. ; Loop forever (until we explicitly use ExitLoop) While 1 ; Do the PixelSearch() $coord75 = PixelSearch( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) ; You must check @error immediately after the function that may have set the error; in this case, immediately after PixelSearch() ; Check $coord75 HERE as well, BEFORE you try to access it as an array in MouseClick() If @error Or Not IsArray($coord75) Then ExitLoop ; Now and ONLY now is it safe to call MouseClick() MouseClick("left", $coord75[0] + 15, $coord75[1] + 5, 1 , 0) Sleep(200) WEnd Sleep(100) Edited October 2, 2011 by Unsigned 1 Dgameman1 reacted to this . Share this post Link to post Share on other sites
Dgameman1 10 Posted October 2, 2011 This is what you want. Explanation is in the comments since you seem to learn better that way. ; Loop forever (until we explicitly use ExitLoop) While 1 ; Do the PixelSearch() $coord75=PixelSearch ( 25, 150, 766, 534, 0x13D926, 0 , 1, "[TITLE:WindowLawl]" ) ; You must check @error immediately after the function that may have set the error, in this case, immediately after PixelSearch() If @error Then ExitLoop ; You must check $coord75 here, BEFORE you try to access it as an array in MouseClick() If Not isArray($coord75) Then ExitLoop ; Now and ONLY now is it safe to call MouseClick() MouseClick("left", $coord75[0] + 15, $coord75[1] + 5, 1 , 0) Sleep(200) WEnd Sleep(100) Thank you very much and sorry for all the commotion Share this post Link to post Share on other sites