Jump to content

Alittle help with pixels


 Share

Recommended Posts

Okay basicly i need it to look for the pixel untill it shows up because the pixel only shows up once in a while its not constant so when the pixel shows up i need it to move the mouse to that pixel witch i got it figured out but the while 1 wend keeps searching for the pixel even know its there here is the code i use atm

winmove("Tournament " & $T  & " Lobby","",0,0)
Sleep(1200) 
  
$C = PixelSearch(4,462,317,513,0x141412)
IF @error Then
while 1
$C = PixelSearch(4,462,317,513,0x141412)
MouseMove($C[0],$C[1],0)
sleep(200)
MouseDown("left")
MouseUp("Left")
WEnd
EndIf
Link to comment
Share on other sites

So you want to Look for the Pixel, then once its found perform your Left click then Exit ?

winmove("Tournament " & $T  & " Lobby","",0,0)
Sleep(1200)

while 1
    $C = PixelSearch(4,462,317,513,0x141412)
    If IsArray($C) Then ;if pixel found then do this, Else keep lookin for the Pixel
        MouseMove($C[0],$C[1],0)
        sleep(200)
        MouseDown("left")
        MouseUp("Left")
        ExitLoop 
    EndIf
WEnd

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

So you want to Look for the Pixel, then once its found perform your Left click then Exit ?

winmove("Tournament " & $T  & " Lobby","",0,0)
Sleep(1200)

while 1
    $C = PixelSearch(4,462,317,513,0x141412)
    If IsArray($C) Then ;if pixel found then do this, Else keep lookin for the Pixel
        MouseMove($C[0],$C[1],0)
        sleep(200)
        MouseDown("left")
        MouseUp("Left")
        ExitLoop 
    EndIf
WEnd

Thank you but can you brake this down in a little more detail what i mean is like for example what is exitloop for? wouldn't just WEnd be safficiant??

Link to comment
Share on other sites

The WEnd simply designates where to begin looping back to the While statement. As long as the While {condition} statement is true (and by being "While 1" it will always be true) it will continue looping until your computer melts or untill you provide another way out of the loop, maybe by quitting the script or shutting down the system or by using task manager to kill it.

The ExitLoop command makes the script go on to the next command in the script after the WEnd statement, in your case nothing which effectively quits the script

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

will continue looping until your computer melts

Lol, good catch. My Bad. Its always a good idea to add a sleep in ur loop so u dont peg ur CPU out.

winmove("Tournament " & $T  & " Lobby","",0,0)
Sleep(1200)

while 1
    $C = PixelSearch(4,462,317,513,0x141412)
    If IsArray($C) Then ;if pixel found then do this, Else keep lookin for the Pixel
        MouseMove($C[0],$C[1],0)
        sleep(200)
        MouseDown("left")
        MouseUp("Left")
        ExitLoop 
    EndIf
    Sleep(20)
WEnd

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

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