Jump to content
Sign in to follow this  
Guest nait

While-Loop for Noobs

Recommended Posts

Guest nait

Hi!

If i want to let the following script run, it says

"WEnd" statement with no matching "While" statement

Heres the code:

$count = 1
While $count = 1
    If PixelGetColor( 770 , 473 ) = 7701591 Then
    MouseClick ( "left", 720, 475)
    else $count = 0
WEnd

What did i do wrong?

thx in advance

Share this post


Link to post
Share on other sites
MSLx Fanboy

No EndIf statement, it looks through the entire script for EndIf first, so WEnd is skipped because End-of-File is already reached


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites
buzz44

@nait

Cough... I think you forgot something.

Fixed version your code...

$count = 1
While $count = 1
   If PixelGetColor( 770 , 473 ) = 7701591 Then
      MouseClick ( "left", 720, 475)
   Else
      $count = 0
   EndIf
WEnd

Personal way of doing it...

While 1
   If PixelGetColor( 770 , 473 ) = 7701591 Then
      MouseClick ( "left", 720, 475)
      ExitLoop
   EndIf
WEnd
Edited by Burrup

qq

Share this post


Link to post
Share on other sites
MSLx Fanboy

hehe, i didn't even catch that...sorry


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites
quick_sliver007

Personal way of doing it...

While 1
   If PixelGetColor( 770 , 473 ) = 7701591 Then
      MouseClick ( "left", 720, 475)
      ExitLoop
   EndIf
WEnd

<{POST_SNAPBACK}>

I think he wants to exitloop if the pixel doesn't match.

like.....

While 1
    If PixelGetColor( 770 , 473 ) <> 7701591 Then 
        ExitLoop
    EndIf
    MouseClick ( "left", 720, 475)
WEnd

.

Share this post


Link to post
Share on other sites
buzz44

Thanks quick_sliver007, I replied in a rush and must of overlooked.


qq

Share this post


Link to post
Share on other sites
quick_sliver007

Thanks quick_sliver007, I replied in a rush and must of overlooked.

<{POST_SNAPBACK}>

You welcome, I do the same thing sometimes and end up tring to edit the post before someone see it. :)

.

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  

×