Sean's
RemoveTrayIcon function (see above) already does AddTrayIcon, as long as it's passed the proper parameters.
For example, if one were to add this to Sean's script:
Code:
Process, Exist
WinGet, hWnd,, ahk_pid %ErrorLevel%
RemoveTrayIcon(hWnd,999,0,0,0)
you would already have a new blank icon. I changed the hWnd to the current one, the uID to a random one, a blank nMsg, a blank hIcon and the command to ADD (which is 0, while MODIFY is 1 and REMOVE is 2).
An interesting script would be the following:
Code:
#Persistent
DetectHiddenWindows, On
Process, Exist
WinGet, hWnd,, ahk_pid %ErrorLevel%
AddTrayIcon(hWnd,101,0,0,0)
AddTrayIcon(hWnd,102,0,0,0)
AddTrayIcon(hWnd,103,0,0,0)
AddTrayIcon(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
VarSetCapacity(ni, 68, 0)
EncodeInteger(&ni + 0, VarSetCapacity(ni))
EncodeInteger(&ni + 4, hWnd)
EncodeInteger(&ni + 8, uID)
EncodeInteger(&ni +12, 1|2|4)
EncodeInteger(&ni +16, nMsg)
EncodeInteger(&ni +20, hIcon)
DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
}
EncodeInteger(ref, val, nSize = 1)
{
DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", nSize * 4, "Uint", val)
}
Why would anyone want that? Well, there are
some people who place controls on the taskbar and need some "spacers"...