Jump to content

How do I run multiple loops @ the same time?


Recommended Posts

Hello every1!!  :D

I need to run several loops at once within the same script...how??  :idiot:

Thanx!! ;)

Btw, what I'm doing is................a time machine............ :lol:

<{POST_SNAPBACK}>

For having them run at EXACTLY the same time you have to have multiple autoit programs running.

Otherwise you can mix all the functions withen ONE loop.

You can also nest them by just having the loop withen the loop like:

For $countA = 1 To 5
     For $countB = 1 to 5
          MsgBox(0,'',$countA & @CRLF & $countB)
     Next
Next
Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Link to comment
Share on other sites

This is possibly closest thing to 2 loops at once, that you can have.

You can have several functions in the main while loop.

$x is just inserted, to make it safely stop at 10 loops.

example:

Run('notepad')

$x = 1
while $x < 10
   $x = $x + 1
   WinWaitActive('Untitled')
   Send(@sec & 'loop' & @cr)
   loop()
WEnd

Func loop()
   While 1
      WinWaitActive('Untitled')
      Send(@sec & 'func' & @cr)
      ExitLoop
   WEnd
EndFunc
Link to comment
Share on other sites

For running your script code in concurrent pathes you would need threads.

Sorry currently no threads support for scripts in AutoIt.

(As far as i know the AutoIt engine uses additional threads when needed, but does not expose threading to direct use by scripts.)

Alternatively You can split Your code and run it in parallel processes by starting multiple AutoIt scripts.

Link to comment
Share on other sites

What about adding FileRead and FileWrite to the loops that both scripts will access?

That way you could make sure that both scripts have access to the variables you need?

Set up a section that will poll the file for the variable you're looking for about once every 250 to 500 msec

Edited for spelling

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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