Alan502 Posted November 21, 2010 Share Posted November 21, 2010 Hey everybody, I'm new to AutoIt and it's a very impressive scripting language. I've seen great stuff around made with it. What I'm trying to do is that, when the script starts, a certain instruction will wait 10 minutes to execute while the rest of the code will continue as normal. I think they call it multi-threading but I'm not very good in the subject. Thanks in advance. Link to comment Share on other sites More sharing options...
SadBunny Posted November 21, 2010 Share Posted November 21, 2010 Are you explicitly looking to multiple threads? Because you can easily do this kind of thing from one script, by using _DateDiff() to compare timestamps and just do some code when the time difference is greater than 10 minutes between now and the last time a timestamp was created. Coincidentally I wrote an example script yesterday for another thread which demonstrated my take on that. Don't know if it helps but it can never hurt to post a working example #include $initialDateTimeStamp = _NowCalc() $lastDateTimeStamp = _NowCalc() $currentDateTimeStamp = _NowCalc() $intervalInSeconds = 5 ConsoleWrite("Initial date/time stamp: " & $initialDateTimeStamp & @CRLF) While 1 $currentDateTimeStamp = _NowCalc() If _DateDiff('s', $lastDateTimeStamp, $currentDateTimeStamp) >= $intervalInSeconds Then ConsoleWrite("Another " & $intervalInSeconds & " seconds have passed!" & @CRLF) ConsoleWrite("Difference with last time stamp: " & _DateDiff('s', $lastDateTimeStamp, $currentDateTimeStamp) & @CRLF) ConsoleWrite("Difference with initial time stamp: " & _DateDiff('s', $initialDateTimeStamp, $currentDateTimeStamp) & @CRLF) ConsoleWrite("Current date/time: " & $currentDateTimeStamp & @CRLF) $lastDateTimeStamp = $currentDateTimeStamp EndIf Sleep(100) WEnd Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Alan502 Posted November 21, 2010 Author Share Posted November 21, 2010 (edited) Thanks SadBunny, I think DateDiff is just what I need , I also found TimeInit() and TimeDiff() which I think are the functions i'll use.AdlibRegister sounds interesting though, is the function executed while the program is still running or does it pause the program anyways?Edit: I checked the help twice and it says that Adlib does pause the main script. Which one should I use then? Does Adlib use less resources? Edited November 21, 2010 by Alan502 Link to comment Share on other sites More sharing options...
martin Posted November 21, 2010 Share Posted November 21, 2010 Thanks SadBunny, I think DateDiff is just what I need , I also found TimeInit() and TimeDiff() which I think are the functions i'll use.AdlibRegister sounds interesting though, is the function executed while the program is still running or does it pause the program anyways?Edit: I checked the help twice and it says that Adlib does pause the main script. Which one should I use then? Does Adlib use less resources?It really depends on what you need to happen. Making the script continue and having a certain function start after a delay of a few minutes is ok, but if you then want the certain function to be executing at the same time as the rest of the script executes then you can't do that with one script in AutoIt. If the certain function finishes quickly then the rest of the script can continue when it's finished then AdLIbRegister would do fine. Otherwise you could still use AbLibRegister but replace the certain function with a call to run another exe or script which can then run at the same time. If the two need to swap information then you could use messages. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
James Posted November 22, 2010 Share Posted November 22, 2010 Otherwise you could still use AbLibRegister but replace the certain function with a call to run another exe or script which can then run at the same time. If the two need to swap information then you could use messages.You could probably keep all the code in the same place if it requires using information your code computes.Use $CMDLine arguments to determine if your program is re-opening again. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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