Jump to content

Multiple loops at once


Recommended Posts

How do I get 2 loops rolling at once?

For example:

While 1
 Msgbox (0, "Some Box", "Some Text")
 Sleep (3000)
Wend

While 1
 Msgbox (0, "Another Box", "Some Other Text")
 Sleep (5000)
Wend

How do I make both work together? So every 3 seconds I get an message and every 5 seconds I get another, regardless of what the other is doing.

The reason I want it, is so I can have something happen on one side of a window (in a label) and something else to happen on the other side (in another label).

Link to comment
Share on other sites

I'm not sure thats possible, but heres a work around:

$Timer1 = TimerInit()
$Timer2 = TimerInit()
While 1
If TimerDiff($Timer1) > 3000 Then ;Check timer 1 ">" because its not always dead-on
Msgbox (0, "Some Box", "Some Text")
$Timer1 = TimerInit() ;reset timer
EndIf
If TimerDiff($Timer2) > 5000 Then
Msgbox (0, "Another Box", "Some Other Text")
$Timer2 = TimerInit()
EndIf
WEnd

Letme check this real quick, to make sure it works

EDIT: made some changes but that should work XD

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

One other workaround is to have your script write two(or one if you wanna keep it "tight") temporary script(s), then run them from your (compiled) program,

have a look in the help file under the section Using AutoIt -> Command Line Parameters.

Edited by FreeFry
Link to comment
Share on other sites

Other than these workarounds there's no 'real' (real as in built-in) way to 'multi-task' like other multi-threaded languages do(autoit is single threaded, except for some functions) I'm afraid. :/

that is disapointing to read :)
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...