Chaz Posted December 27, 2005 Share Posted December 27, 2005 Hi, i was wondering if there was any way i can run two loops at the same time For example, in Turing there is something called Process which ran code at the background while the ptr is doing some other functions etc. I was wondering if there was something like this for Autoit as well? I just started Using Autoit for a few days and i've looked everywhere in the help file and couldn't find anything that could help me. Thank you very much Link to comment Share on other sites More sharing options...
LxP Posted December 27, 2005 Share Posted December 27, 2005 Welcome to the forums Chaz! Multi-threading is not possible with AutoIt v3. The easiest solution is to run two separate AutoIt scripts simultaneously. There are some cases however where clever scripting can give the illusion of two things happening at once. Link to comment Share on other sites More sharing options...
themax90 Posted December 27, 2005 Share Posted December 27, 2005 While 1 If $Variable Then DoFunc() ; Otherwise background code... WEnd Or Do ; Background code Until DoFunc() = -1 Func DoFunc() If Random(1, 500, 1) >= 300 Then Return -1 Return 0 EndFunc There are other similar solutions but I have no idea what you are talking about. Link to comment Share on other sites More sharing options...
Chaz Posted December 27, 2005 Author Share Posted December 27, 2005 Thank you for your fast replies. The problem i am currently having deals with timers I want function A to run with timer A without the delay from running function B of Timer B, and vice versa. Unfortunately AutoIt Smith, your suggestions won't work =/ thanks though. I have to make them both independant of each other. I suppose I will try running two scripts, it sounds the most simplistic right now. If anyone can think of a way to do this I would greatly appreciate it. Link to comment Share on other sites More sharing options...
LxP Posted December 27, 2005 Share Posted December 27, 2005 I suspected that you wanted to take two actions at differing intervals. This is the kind of case that I was talking about. Try this code on for size: Local $Timer1, $Delay1 = 5000 Local $Timer2, $Delay2 = 1000 While 1 If $Timer1 = '' Or TimerDiff($Timer1) > $Delay1 Then $Timer1 = TimerInit() Action1() EndIf If $Timer2 = '' Or TimerDiff($Timer2) > $Delay2 Then $Timer2 = TimerInit() Action2() EndIf ; Briefly pause to avoid excessive CPU usage Sleep(100) WEnd Func Action1() ; Instructions for action 1 here EndFunc Func Action2() ; Instructions for action 2 here EndFunc Link to comment Share on other sites More sharing options...
Chaz Posted December 27, 2005 Author Share Posted December 27, 2005 Wow, thanks! I think this will work perfectly! Thank you very much =) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now