Jump to content

Miliseconds


Recommended Posts

Hi, have been search in the forum but i cannot find anything about using miliseconds in a clock or similar...

My problem is to create a NAMEFILE based on day, month, year, hour, minute, second.... and i have to use one more (milisecond) but i don't have a clue how to get the milisecond

Can someone help me!!!! :">

Link to comment
Share on other sites

Timer that displays milliseconds...

$sec = @SEC
While $sec <> @SEC
WEnd

$mill = TimerInit() ;syncs millicond with current time

While 1
    $sec = @SEC
    ToolTip(@hour & ":" & @MIN & ":" & @SEC & ":" & Round(TimerDiff($mill),0))
    If @SEC > $sec Or TimerDiff($mill) > 1000 Then $mill = TimerInit()
WEnd
Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

Hi,

Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))
    $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    $stSystemTime = 0
    Return $sMilliSeconds
EndFunc   ;==>_MSec

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))
    $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    $stSystemTime = 0
    Return $sMilliSeconds
EndFunc   ;==>_MSecoÝ÷ Ù*%¢xz¿ªê-xØ{}ÇiÛh¦ëb¶)Úué¨jëh×6#include <array.au3>
Dim $avTimes[21]
For $t = 1 To 20
    $avTimes[$t] = @HOUR & ":" & @MIN & ":" & @SEC & "." & _MSec()
    Sleep(1) ; Without Sleep() all the times are the same!
Next
_ArrayDisplay($avTimes, "Time Test")


Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))
    $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    $stSystemTime = 0
    Return $sMilliSeconds
EndFunc   ;==>_MSec

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Couldn't you just take 1000 * seconds? That is, if AutoIt allows math :/ Something like this:

$secs = InputBox("Seconds", "Input seconds:", " ")
$millis = $secs * 1000

That's just the variables... Anyone could do that, but it could give some ideas? Lol. Good luck.

Edited by Runite
Link to comment
Share on other sites

Couldn't you just take 1000 * seconds? That is, if AutoIt allows math :/ Something like this:

$secs = InputBox("Seconds", "Input seconds:", " ")
$millis = $secs * 1000

That's just the variables... Anyone could do that, but it could give some ideas? Lol. Good luck.

That is exactly how you calculate a millisecond in relation to a second. But I believe the original poster wanted the current time to the millisecond, if i understand correctly.
Link to comment
Share on other sites

Couldn't you just take 1000 * seconds? That is, if AutoIt allows math :/ Something like this:

$secs = InputBox("Seconds", "Input seconds:", " ")
$millis = $secs * 1000

That's just the variables... Anyone could do that, but it could give some ideas? Lol. Good luck.

Read the posts and understand what to goal is. If that's all you want just do _TimeToTicks(). But this topic is about getting the time down to the millisecond. Which th.meger's function does quite nicely.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Yes, my post worked fine. Yet people still post....

No, I don't think it quite did. Your script depends on waiting for the rollover of @SEC to sync, which means it takes a minimum average of 500msec to run. If you run my demo of th.meger's script and comment out the sleep, you'll see he can get at least 20 executions done in less than a millisec. Your version would be useless to time-tag mulltiple events that happened in less than a second.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

No, I don't think it quite did. Your script depends on waiting for the rollover of @SEC to sync, which means it takes a minimum average of 500msec to run. If you run my demo of th.meger's script and comment out the sleep, you'll see he can get at least 20 executions done in less than a millisec. Your version would be useless to time-tag mulltiple events that happened in less than a second.

:whistle:

No. But nice guess.

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...