nf67 Posted March 25, 2010 Posted March 25, 2010 Hi there,what I had expected to be pretty easy in theory didn't turn out the way I had wanted it to.I have my script which just does all kinds of things, but every 10 seconds I need a certain function to be run.I put a TimerInit() at the start (before the loop) and used TimerDiff in the loop, but this didn't work.Here's an example:$Timer = TimerInit() While 1 If IsInt(TimerDiff($Timer) / 10000) = 1 Then MsgBox(0,"","(Another) 10 seconds have passed") EndIf WEndWhat's a better way of doing this ?Checking if TimerDiff($Timer) > 10000 and then resetting the timer?Thanks!P.S: Perhaps it's because when checking the time it'll never be a integer, because it just skips that time doing other things, resulting in the time being 17.98876 the first time and 18.00256 the second time it polls, for example. If this is the case then putting more code in the loop will only make it more inaccurate I think, and my script obviously has a lot more in the loop than the example does.
Fulano Posted March 25, 2010 Posted March 25, 2010 (edited) You are going to chew alot of cycles this way, how accurate does this need to be? Perhaps a Sleep(1000) in there would smooth things out by giving other things a chance to run. Also, for the check, this may or may not run faster:Mod(TimerDiff($Timer), 10000) < 500 Edited March 25, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
KaFu Posted March 25, 2010 Posted March 25, 2010 Check out AdlibRegister() or _Timer_SetTimer(). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
GodlessSinner Posted March 25, 2010 Posted March 25, 2010 (edited) AdlibEnable ( "test" 10000) While 1 sleep(100) Wend Func test() MsgBox(0, "", "test") EndFunc Edited March 25, 2010 by wwwvgtulzcomua _____________________________________________________________________________
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