Jump to content

Search the Community

Showing results for tags 'Timer UDF'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. Hello everyone I am encountering a strange problem with timers... i.e wrong time difference . This is an test script made by me to compare Arrays & Maps in terms of speed, I wanted publish the results in my Maps topic, so I am hiding the question in the spoiler to prevent spoilage If you run the script(s), you can see that sometimes the time difference is >1 but the actual difference is almost instantaneous, I don't know what is causing the problem, I think the problem is in my end this time because I used both native and UDF functions and they return identical results... However I spotted something interesting in the documentation for TimerDiff: "Remarks: Some processors are known to cause the function to return incorrect result." Hmmm.... is my processor the culprit? Or is something wrong in my script... Thanks in Advance! TD P.S It was hard to write in the dark spoiler
  2. Here is my wrapper for SetTimer and KillTimer APIs. AutoIt already has its own, but I tried to make it as simple as I could. #include-once Global $g_avSimpleTimers = [[0, 0]] Func TimerSet($vFunction, $uInterval) Local $hFunction = DllCallbackRegister($vFunction, "none", "HWND;UINT;UINT_PTR;DWORD") If ($hFunction = 0) Then Return 0 Local $uTimerId = DllCall("user32.dll", "UINT_PTR", "SetTimer", _ "HWND", 0, _ "UINT_PTR", 0, _ "UINT", $uInterval, _ "ptr", DllCallbackGetPtr($hFunction))[0] If ($uTimerId = 0) Then DllCallbackFree($hFunction) Return 0 EndIf ReDim $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 2][2] $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 1][0] = $uTimerId $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 1][1] = $hFunction $g_avSimpleTimers[0][0] += 1 Return $uTimerId EndFunc Func TimerUnset($uTimerId) If ($g_avSimpleTimers[0][0] = 0) Then Return False Local $iCount = $g_avSimpleTimers[0][0] For $i = 1 To $iCount + 1 If ($g_avSimpleTimers[$i][0] = $uTimerId) Then DllCall("user32.dll", "BOOL", "KillTimer", _ "HWND", 0, _ "UINT_PTR", $uTimerId) DllCallbackFree($g_avSimpleTimers[$i][1]) For $j = $i To $iCount - 1 $g_avSimpleTimers[$j][0] = $g_avSimpleTimers[$j + 1][0] $g_avSimpleTimers[$j][1] = $g_avSimpleTimers[$j + 1][1] Next $g_avSimpleTimers[0][0] = $iCount - 1 ReDim $g_avSimpleTimers[$iCount][2] Return True EndIf Next Return False EndFunc Example: #include "Simple Timers.au3" Global $t1 = TimerSet(Foo, 500) Global $t2 = TimerSet("Bar", 1000) MsgBox(0, "", "Check the console.") TimerUnset($t1) MsgBox(0, "", "Check the console again.") TimerUnset($t2) ;Not necessary if you are exiting the script Func Foo($a, $b, $c, $d) ConsoleWrite(">Foo" & @CRLF) EndFunc Func Bar($a, $b, $c, $d) ConsoleWrite("!Bar" & @CRLF) EndFunc Download both UDF and example:
×
×
  • Create New...