Jump to content

milli or microseconds wanted


Recommended Posts

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 years later...

adding this under the arraydisplay in monoceres example?

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

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

Link to comment
Share on other sites

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

Edited by iamtheky

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

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...