Jump to content

Recommended Posts

Posted

You could do like this (example) - but depending of the use there are probably simpler ways to get the same result...

#include <Timers.au3>

HotKeySet("{ESC}", "Terminate")
Tooltip(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 0, 0)

_Example_CallBack()

Func _Example_CallBack()
    Local $hGUI = WinGetHandle(AutoItWinGetTitle())
    _Timer_SetTimer($hGUI, 1000, "_UpdateTip") ; create timer
    While 1
       Sleep(10)
    WEnd
EndFunc   ;==>_Example_CallBack

; call back function
Func _UpdateTip($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    Tooltip(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 0, 0)
EndFunc   

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Posted (edited)

Thanks.

Just a suggestion, maybe it's my error in interpretation, but I think it would be a good idea to add the "WinGetHandle(AutoItWinGetTitle())" as a part of the remarks, because the way the help is worded lead me to believe that without a gui window existing in the script calling the timer function it would not work. "Handle to the window to be associated with the timer. This window must be owned by the calling thread". Or something a little clearer.

Edited by Champak
Posted

It seems that the hwnd can be 0 :

_Timer_SetTimer(0, 1000, "_UpdateTip")

MSDN says : A handle to the window to be associated with the timer. This window must be owned by the calling thread. If a NULL value for hWnd is passed in along with an nIDEvent of an existing timer, that timer will be replaced in the same way that an existing non-NULL hWnd timer will be.
https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms644906(v=vs.85).aspx

 

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
  • Recently Browsing   0 members

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