Jump to content

Click a color until it's gone


Recommended Posts

@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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers

I'm checking to see if the color changed with the until @error

No 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.
  :)

Link to comment
Share on other sites

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)

???

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

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 =/

Link to comment
Share on other sites

  • Developers

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 :graduated:

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.
  :)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Test your code and see if you get the desired results.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 by Dgameman1
Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

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 by Dgameman1
Link to comment
Share on other sites

  • Developers

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

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.
  :)

Link to comment
Share on other sites

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 by Dgameman1
Link to comment
Share on other sites

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 by Unsigned

.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...