#include <FontConstants.au3>
#include <HotKey.au3>
#include <vkConstants.au3>
#include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Opt('TrayAutoPause', 0)
Global $hAutoIt = WinGetHandle(AutoItWinGetTitle())
Global $Count = 0, $hPrev = 0
HotKeySet('{Esc}', '_Exit')
_SetAutoItIcon($Count, 0xFF0000, 0xFFD700)
;_HotKeyAssign($VK_F5, '_Increment', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_NOBLOCKHOTKEY))
While 1
Sleep(100)
_Increment()
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _Increment()
$Count += 1
If $Count > 999 Then
$Count = 0
EndIf
_SetAutoItIcon($Count, 0xFF0000, 0xFFD700)
EndFunc ;==>_Increment
Func _SetAutoItIcon($iCount, $iColor = 0x000000, $iBkColor = 0xFFFFFF)
Local $hDC, $hBitmap, $hMask, $hIcon, $hFont, $tNID, $tRect
$hDC = _WinAPI_CreateCompatibleDC(0)
$hBitmap = _WinAPI_CreateSolidBitmap(0, $iBkColor, 16, 16)
$hMask = _WinAPI_CreateBitmap(16, 16, 1, 1)
$hFont = _WinAPI_CreateFont(18, 4, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Tahoma')
$tRect = _WinAPI_CreateRectEx(1, 0, 15, 16)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_SelectObject($hDC, $hFont)
_WinAPI_SetTextColor($hDC, $iColor)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor($iBkColor))
_WinAPI_DrawText($hDC, $iCount, $tRect, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
_WinAPI_DeleteDC($hDC)
$hIcon = _WinAPI_CreateIconIndirect($hBitmap, $hMask)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteObject($hMask)
_WinAPI_DeleteObject($hFont)
$tNID = DllStructCreate($tagNOTIFYICONDATA)
DllStructSetData($tNID, 'Size', DllStructGetSize($tNID))
DllStructSetData($tNID, 'hWnd', $hAutoIt)
DllStructSetData($tNID, 'Flags', $NIF_ICON)
DllStructSetData($tNID, 'ID', 1)
DllStructSetData($tNID, 'hIcon', $hIcon)
_WinAPI_ShellNotifyIcon($NIM_MODIFY, $tNID)
If $hPrev Then
_WinAPI_DestroyIcon($hPrev)
EndIf
$hPrev = $hIcon
EndFunc ;==>_SetAutoItIcon