Jump to content
Sign in to follow this  
Dgameman1

Click a color until it's gone

Recommended Posts

Dgameman1

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
Dgameman1

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

Share this post


Link to post
Share on other sites
water

@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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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

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
Dgameman1

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

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:
  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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

Then I would advice you to start learning the language first before writing your 2000 lines scripts :graduated:

=P

As of now it's 2,666 =P

So, where can I actually understand what @error does?

Could you give me an example?

Share this post


Link to post
Share on other sites
Dgameman1

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

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

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Dgameman1

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

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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

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

Share this post


Link to post
Share on other sites
Jos

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

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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

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

Share this post


Link to post
Share on other sites
Unsigned

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
  • Like 1

.

Share this post


Link to post
Share on other sites
Dgameman1

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

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
Sign in to follow this  

×