Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Write 2 digit numbers to the system tray icon


  • Please log in to reply
16 replies to this topic
  • Guests
  • Last active:
  • Joined: --
Hi everyone,

Original script is now dead link, but I've tried the GDI+ version.
Seems really fine, except for the font size: it's almost unreadable because it's tiny.

I tried to increase the font size but then it seems to be too wide for the 16x16 grid...
I tried to increase the icon size to 32*32, but that got worst =)

Any idea ? Thanks !

Kudos
  • Members
  • 39 posts
  • Last active: Sep 27 2015 09:06 AM
  • Joined: 21 Aug 2006

I know this is a really old thread but here is the version that gives bigger numbers if anyone is still looking! :)
 

#SingleInstance, Force
#NoTrayIcon


pToken := Gdip_Startup()
x := 1, d := 0
SetTimer, Update, 300
return


;#####################################################################################


Update:
SetTrayNumber(x)
if (x < 0 || x > 99)
d := !d
x := d ? --x : ++x
return


;#####################################################################################


Esc::
Gdip_Shutdown(pToken)
ExitApp
return


;#####################################################################################


SetTrayNumber(Number, TextColour=0xffffff00, BackgroundColour=0x00ff0000)
{
if (Number < 0 || Number > 99)
return -1
if !hFamily := Gdip_FontFamilyCreate("Tahoma")
return -2
Gdip_DeleteFontFamily(hFamily)
pBitmap := Gdip_CreateBitmap(16, 16), G := Gdip_GraphicsFromImage(pBitmap)
Gdip_FillRectangle(G, pBrush := Gdip_BrushCreateSolid(BackgroundColour), 0, 0, 16, 16)
Gdip_DeleteBrush(pBrush)
pBrush := Gdip_BrushCreateSolid(TextColour)
Gdip_TextToGraphics(G, Number, "x-2 y0 w20 h20 Center r4 s12 Bold c" pBrush, "Tahoma")
Gdip_DeleteBrush(pBrush)
hIcon := Gdip_CreateHICONFromBitmap(pBitmap)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap)
VarSetCapacity(nid, 444, 0)
NumPut(444, nid, 0)
if A_IconHidden
Menu, Tray, Icon
DetectHiddenWindows, On
Process, Exist
NumPut(WinExist("ahk_class AutoHotkey ahk_pid " ErrorLevel), nid, 4)
DetectHiddenWindows, Off
NumPut(1028, nid, 8), NumPut(hIcon, nid, 20), NumPut(0x2, nid, 12)
DllCall("shell32\Shell_NotifyIcon", "uint", 0x1, "uint", &nid)
DestroyIcon(hIcon)
return 0
}


#Include gdip.ahk