Jump to content

possible to have 2 whiles in the same script?


Recommended Posts

Yeh I know it is kinda strange but .. I've got to seperate 'while parts' in my script and I can't get it working...

But if I run them as two seperate scripts they are working fine.. any solutions?

opt ( "Mousecoordmode" , 2 )
opt ( "Pixelcoordmode" , 2 )



While 1

$coord = PixelSearch( 496, 553, 497, 554, 0x680707 , 10 )

If Not @error Then


MouseMove ( 521, 550, 1 )


    Sleep (2000)
    MouseClick ("Left")

Sleep (10000)


MouseMove ( 506, 222, 1 )

Sleep (2000)
MouseClick ("Right")
Sleep (2000)
MouseMove ( 160, 250, 1 )
Sleep (2000)
MouseClick ("Left")
Sleep (2000)
MouseMove ( 194, 341, 1 )
MouseClick ("Left")
Sleep (2000)
MouseMove ( 199, 529, 1 )
MouseClick ("Left")
Sleep (500)
EndIf

WEnd


While 1

$coord = PixelSearch( 404, 192, 405, 193, 0x680707 , 10 )

If Not @error Then
    
    MouseMove ( 404, 192, 1 )
    Sleep (1000)
    MouseClick ("Left")

Sleep (500)
EndIf

WEnd
Link to comment
Share on other sites

Yes I want both of them to run at the same time.

I was thinking of putting them into the same while loop, but it's not good because I don't want the shorter one to wait each time all the sleeps that the bigger on contains..

You can't run them both at the same time (that would be some kind of multi-tasking) BUT I think there are some things in AutoIt that let you run functions at intervals (preset or not).

Check out AdlibEnable but that may be just a silly work around to doing what you want to do. Using AdlibEnable, I think, AutoIt will run whatever function you assign to AdlibEnable but it pauses the rest of AutoIt. This isn't exactly what it was designed for but more for handling those unexpected errors/messages that don't happen everytime during during installs.

I am sure there are a few nicer ways to do that though.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

You could also make your second loop a function that runs for two seconds and call it rather than sleeping in your While loop.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

try looking at it this way... like larry said

do
$search_a = PixelSearch(?????)
$search_b = PixelSearch(?????)

If $search_a <> 1 then
;do whatever you want if the $search_a has found the pixel
elseif $search_b <>1 then
;do whatever if the $search_b has found the pixel
endif
until _ispressed("01")

this obvioulsy is not a working script, but will get you the general idea........ it also depends on what you plan on doing when it has found the pixel and what how long that action will take.....(like how many times are you scanning for that pixel in milliseconds)...

Edited by Aceguy
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...