Jump to content

difference between "_Timer_Init()" and "TimerInit()" ?


Recommended Posts

  • Moderators

Sven,

TimerInit is an native AutoIt function - so the last version where you can see the actual code used is v3.1.0 from 2005. Whether this remains unchanged in the current release version I have no idea.

_Timer_Init is a UDF function which calls the QueryPerformanceCounter function of kernel32.dll.

I have never used the UDF function as the native version has always sufficed for my needs so I cannot comment on any differences in behaviour. However, I would not mix the two sets of function - if you use TimerInit then you should use TimerDiff to get the result. ;)

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

Thanks. They both seem to call QueryPerformanceCounter (3.1.0 source does at least) and they both seem equally precise. Since I'm not having any eureka! moments concerning the difference between the two I'm going to use the one that requires less typing ;)

Edited by Sven
Link to comment
Share on other sites

  • Moderators

Sven,

Sounds like a very reasonable decision! :)

M23

Zedna,

Just seen your post. What you say is true for _Timer_SetTimer vs Adlib but here we are talking about measuring a delay from a fixed timestamp which can only be done within the running script and so there should be no difference - and there seems not to be:

#include <GUIConstantsEx.au3>
#include <Timers.au3>

$hGUI = GUICreate("Test", 500, 500)
$cLabel_Native = GUICtrlCreateLabel("0", 10, 10, 200, 20)
$cLabel_UDF = GUICtrlCreateLabel("0", 10, 50, 200, 20)
GUISetState()

$iBegin_Native = TimerInit()
$iBegin_UDF = _Timer_Init()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $iDelay_Native = Int(TimerDiff($iBegin_Native) / 1000)
    If $iDelay_Native <> GUICtrlRead($cLabel_Native) Then
        GUICtrlSetData($cLabel_Native, $iDelay_Native)
    EndIf

    $iDelay_UDF = Int(_Timer_Diff($iBegin_UDF) / 1000)
    If $iDelay_UDF <> GUICtrlRead($cLabel_UDF) Then
        GUICtrlSetData($cLabel_UDF, $iDelay_UDF)
    EndIf

WEnd

And here is an example of using _Timer_SetTimer to get around a script pausing. ;)

Edited by Melba23

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

Zedna,

Just seen your post. What you say is true for _Timer_SetTimer vs Adlib but here we are talking about measuring a delay from a fixed timestamp which can only be done within the running script and so there should be no difference - and there seems not to be:

Of course you are right Melba :-)

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