Jex Posted January 3, 2008 Share Posted January 3, 2008 (edited) I'm curious how TimerDiff calculate time. I'm found using that operation : $Test = TimerInit() Sleep(500) $Test2 = (TimerInit() - $Test) / ((TimerInit() - $Test) / TimerDiff($Test)) MsgBox("", "", $Test2) With that method my functions can find TimerDiff but i'm curious what is 341..... and my second question is TimerInit return which value? How can i get that value without use that function. ( Example dllcall maybe? ) Edited January 3, 2008 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Siao Posted January 3, 2008 Share Posted January 3, 2008 $t1 = TimerInit() $t2 = 0 $a = DllCall('Kernel32.dll', 'int', 'QueryPerformanceCounter', 'int64*', $t2) $t2 = $a[1] MsgBox(0, '', $t1 & @CRLF & $t2) "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Jex Posted January 3, 2008 Author Share Posted January 3, 2008 (edited) Thanks Siao.GaryFrost gave QueryPerformanceCounter in here http://www.autoitscript.com/forum/index.ph...st&p=457702but i'm didn't understood what is that. I'm found that GetTickCount function : http://msdn2.microsoft.com/en-us/library/ms724408.aspx which will be better for create timer?Edit:I'm added 3 timer for test accuracy but QueryPerformanceCounter not give true result :$Timer = TimerI(1) $Timer2 = TimerI(2) $Timer3 = TimerInit() Sleep(534) MsgBox("", "", "Timer : " & TimerD($Timer, 1) & @CRLF & "Timer2 : " & TimerD($Timer2, 2) & @CRLF & "Timer3 : " & TimerDiff($Timer3)) Func TimerI($tType = 1) If $tType = 1 Then $cTimer = DllCall("Kernel32.dll", "int", "GetTickCount") $rTimer = $cTimer[0] Else $cTimer = DllCall("Kernel32.dll", "int", "QueryPerformanceCounter", "int64*", "") $rTimer = $cTimer[1] / 3410000 EndIf Return $rTimer EndFunc Func TimerD($gTimer, $tType = 1) If $tType = 1 Then $cTimer = DllCall("Kernel32.dll", "int", "GetTickCount") $rTimer = $cTimer[0] Else $cTimer = DllCall("Kernel32.dll", "int", "QueryPerformanceCounter", "int64*", "") $rTimer = $cTimer[1] / 3410000 EndIf Return $rTimer - $gTimer EndFuncOk now working i'm added "/ 341" .Why i need divide to 341 ( or 3410000 ) for true result ? Edited January 3, 2008 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Siao Posted January 3, 2008 Share Posted January 3, 2008 (edited) Why i need divide to 341 ( or 3410000 ) for true result ?That's QueryPerformanceFrequencyhttp://msdn2.microsoft.com/en-us/library/ms979201.aspx Edited January 3, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Jex Posted January 3, 2008 Author Share Posted January 3, 2008 (edited) GaryFrost gave QueryPerformanceFrequency in here http://www.autoitscript.com/forum/index.ph...st&p=457702but i'm didn't understood what is that again. Now timers working thanks.TimerI(1) = QueryPerformanceCounter & QueryPerformanceFrequencyTimerI(2) = GetTickCountTımerI(3) = TimerInit & TimerDiffexpandcollapse popup$Timer = TimerI(1) Sleep(534) $Timer = TimerD($Timer, 1) $Timer2 = TimerI(2) Sleep(534) $Timer2 = TimerD($Timer2, 2) $Timer3 = TimerI(3) Sleep(534) $Timer3 = TimerD($Timer3, 3) MsgBox("", "", "Timer : " & $Timer & @CRLF & "Timer2 : " & $Timer2 & @CRLF & "Timer3 : " & $Timer3) Func TimerI($tType = 1) If $tType = 1 Then $cTimer = DllCall("Kernel32.dll", "int", "QueryPerformanceCounter", "int64*", "") Return $cTimer[1] ElseIf $tType = 2 Then $cTimer = DllCall("Kernel32.dll", "int", "GetTickCount") Return $cTimer[0] Else Return TimerInit() EndIf EndFunc ;==>TimerI Func TimerD($gTimer, $tType = 1) If $tType = 1 Then $cTimer = DllCall("Kernel32.dll", "int", "QueryPerformanceCounter", "int64*", "") $fTimer = DllCall("Kernel32.dll", "int", "QueryPerformanceFrequency", "int64*", "") Return 1000 * ($cTimer[1] - $gTimer) / $fTimer[1] ElseIf $tType = 2 Then $cTimer = DllCall("Kernel32.dll", "int", "GetTickCount") Return $cTimer[0] - $gTimer Else Return TimerDiff($gTimer) EndIf EndFunc ;==>TimerD Edited January 3, 2008 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
weaponx Posted January 3, 2008 Share Posted January 3, 2008 TimerDiff() returns the number of ticks since last boot time. Link to comment Share on other sites More sharing options...
Toady Posted January 3, 2008 Share Posted January 3, 2008 Something I wrote a while back.. expandcollapse popup;==================================================================== ; How to simulate the Timer functions in Autoit using DLL calls ;==================================================================== Global $starttime = _TimerInit() While 1 ToolTip(_TimerDiff($starttime)) WEnd ;==================================================================== ; Functions in Autoit ; TimerInit() ; TimerDiff() ; Functions in kernal32.dll ; _QueryPerformanceFrequency() ; _QueryPerformanceCounter() ;==================================================================== Func _TimerInit() Local $var = DllStructCreate("int64") DllCall("kernel32.dll", "int", "QueryPerformanceCounter", "ptr", DllStructGetPtr($var, 1)) Local $starttime = DllStructGetData($var, 1) $startvar = 0 Return $starttime EndFunc Func _TimerDiff($timer) Return 1000 * ( _QueryPerformanceCounter() - $timer ) / _QueryPerformanceFrequency() EndFunc Func _QueryPerformanceFrequency() Local $var = DllStructCreate("int64") DllCall("kernel32.dll", "int", "QueryPerformanceFrequency", "ptr", DllStructGetPtr($var, 1)) Local $returnval = DllStructGetData($var, 1) $var = 0 Return $returnval EndFunc Func _QueryPerformanceCounter() Local $var = DllStructCreate("int64") DllCall("kernel32.dll", "int", "QueryPerformanceCounter", "ptr", DllStructGetPtr($var, 1)) Local $returnval = DllStructGetData($var, 1) $var = 0 Return $returnval EndFunc www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding 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