Jump to content
Sign in to follow this  
trademaid

milli or microseconds wanted

Recommended Posts

trademaid

How can i get milli or better microseconds

ie @HOUR & @min & "." & @sec & "-" & @ms &

Im not after a timer, but want to write to logs with microsecond time stamps

Share this post


Link to post
Share on other sites
Andreik

How can i get milli or better microseconds

ie @HOUR & @min & "." & @sec & "-" & @ms &

Im not after a timer, but want to write to logs with microsecond time stamps

Func _MSec()
    Local $sMilliSeconds
    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

When the words fail... music speaks

Share this post


Link to post
Share on other sites
monoceres

How can i get milli or better microseconds

ie @HOUR & @min & "." & @sec & "-" & @ms &

Im not after a timer, but want to write to logs with microsecond time stamps

The latest beta has a macro called @MSEC

It corresponds to milliseconds ;)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
trademaid

The latest beta has a macro called @MSEC

It corresponds to milliseconds :P

Im delighted with your replies. Thank you. The two things im after is _FileWriteLog in milliseconds, though I guess a workaround for this would be very very easy

@YEAR & @MON & @MDAY ..... @msec

and FileGetTime in milliseconds

Share this post


Link to post
Share on other sites
trademaid

The latest beta has a macro called @MSEC

It corresponds to milliseconds :P

Im delighted with your replies. Thank you. The two things im after is _FileWriteLog in milliseconds, though I guess a workaround for this would be very very easy

@YEAR & @MON & @MDAY ..... @msec

and FileGetTime in milliseconds

Share this post


Link to post
Share on other sites
trademaid

Hi Again

anyone got and FileGetTime in milliseconds?

Share this post


Link to post
Share on other sites
monoceres

Feeling generous today :P

#include <array.au3>
$array=_GetFileTimeEx("Some file.ext")
_ArrayDisplay($array)

; Author monoceres
; Returned array looks like this:
; [0]= year;
; [1]= month
; [2]= day of week
; [3]= day
; [4]= hour
; [5]= minute
; [6]= second
; [7]= millisecond
Func _GetFileTimeEx($file)
    Local $return[8]
    $STruct=DllStructCreate("dword;dword;dword;dword;dword;dword;dword;dword;dword;")
    $filetime=DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
    $call=DllCall("Kernel32.dll","int","GetFileAttributesExW","wstr",$file,"int",0,"ptr",DllStructGetPtr($struct))
    DllCall("Kernel32.dll","int","FileTimeToSystemTime","ptr",DllStructGetPtr($struct,2),"ptr",DllStructGetPtr($filetime))
    For $i=0 To 7
        $return[$i]=DllStructGetData($filetime,$i+1)
    Next
    Return $return  
EndFunc

Enjoy :(

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
trancexx

Looking at that codes I couldn't help noticing that would be really cool to have _StructDisplay() function. Something like _ArrayDisplay().

Then something like this would be possible:

#Include <DllStructure.au3>

$struct = _GetTime()
_StructDisplay($struct)


Func _GetTime()
    
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))
    Return $stSystemTime

EndFunc

...wishes, wishes.

I bet no one can do that! :P


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
littleclown

Hello.

Is there a way to get microseconds? Or 1/10 of a millisecond?

Thank you in advance.

Share this post


Link to post
Share on other sites
iamtheky

adding this under the arraydisplay in monoceres example?

$microseconds = $array[7] * .001
msgbox (0 , '' , $microseconds)
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
littleclown

This will not give me the actual time but just milisecond * 10.

Share this post


Link to post
Share on other sites
iamtheky

nope thats my bad, dont know what i was copying. But 1 microsecond = 0.001 milliseconds. so other than the math....

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Melba23

littleclown,

If you want to use such tiny slivers of time, I suggest you read this topic. It seems that your PC is very unlikely to be able to offer you any degree of accuracy at that level. :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.