E1M1 Posted August 21, 2012 Share Posted August 21, 2012 I found that TimerInit() returns different timestamps on different machines. Time is same on both machines 21 aug 2012 20:33. On 32 bit xp machine I get 17452391718 On 64 bit win 7 (au3 is still 32 bit) I get 94856379079 This difference is huge. Basically I want to add ping command to server - I send ping packet to server and then server sends back the return value of TimerInit() so that I can calculate time difference on client side. Does anyone know what might cause it? Any alternatives to TimerInit() you could suggest? edited Link to comment Share on other sites More sharing options...
BrewManNH Posted August 21, 2012 Share Posted August 21, 2012 TimerInit doesn't return a timestamp, so trying to read what it returns is irrelevant. See bug tracker tickets #2025, and #2008 for more of an explanation. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
E1M1 Posted August 21, 2012 Author Share Posted August 21, 2012 (edited) Thanks for info. Help file said: Returns a timestamp (in milliseconds).Which seems to be wrong in this case. Anything I could use for what I want to do? Edit: I came up with that: based on but these are 2 timestamps that are calculated on same second 607893382656 and 541842352128. Just wondering if anything is wrong with algorithm. Func TimeStamp() Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort') DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime)) $sMilliSeconds = 1 For $i = 1 to 8 $sMilliSeconds *= DllStructGetData($stSystemTime, $i) Next $stSystemTime = 0 Return $sMilliSeconds EndFunc Edited August 21, 2012 by E1M1 edited Link to comment Share on other sites More sharing options...
E1M1 Posted August 21, 2012 Author Share Posted August 21, 2012 I figured that following code gives very random numbers. $time = TimeStamp() Sleep(200) MsgBox(0,0,TimeStamp()-$time) Exit edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2012 Moderators Share Posted August 21, 2012 E1M1,Be careful deciding that number are "random" - randomness is a very difficult concept and the value you are getting from that code is nowhere near random. The Random function uses a very good alogorithm and is as good as you can get for normal purposes. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
E1M1 Posted August 21, 2012 Author Share Posted August 21, 2012 (edited) Sorry for that. By random I meant that when sleep time is always same TimeStamp()-$time is always different. I am currently trying to figure out how to properly convert this to timestamp Edited August 21, 2012 by E1M1 edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2012 Moderators Share Posted August 21, 2012 E1M1,to properly convert this to timestamp_NowCalc. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MvGulik Posted August 21, 2012 Share Posted August 21, 2012 (edited) Timestamp's come in many different flavors. And should not really be shared across different systems (unless your sure there of the same flavor ... and there synchronized down to the lowest(at least) used unit.)For additional information/data on the AutoIt TimeStamp() you might like to take a look at the code in the AutoIt included "Timers.au3" UDF.[edit: something] Edited August 21, 2012 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Kidney Posted August 21, 2012 Share Posted August 21, 2012 TimerInt() should be used with TimerDiff() which is explained here: http://www.autoitscript.com/autoit3/docs/functions/TimerInit.htmthis code will work on any machine:$Timer = TimerInt() Sleep(3000) If TimerDiff($Timer) >= 3000 Then MsgBox(0, "Ding!", "It has been " & Round((TimerDiff($Timer)/1000), 0) & " seconds.") 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