quote:
Originally posted by Matty
This process is long and drawn out
(...)
You need to basically get the handle of the icons and enumerate through them till you find the one relating to msnmsgr.exe.
This isn't true though... To be able to use this Shell_NotifyIcon API you don't need all the fancy stuff -dt- does in his class as that is a serious big unneeded detour.
quote:
Originally posted by Matty
If you want to see an example of getting the handle of the icons take a look at -dt-'s script to change the tooltip of the icon to include your email and status.
[Release] Email tooltip
IMHO, way too complicated and uses many really unneeded stuff.
All you basically need is Shell_NotifyIcon API, nothing more and with that you can indeed change tooltips, remove icons, add icons, etc in only a few lines of codes (no need for hidden plus windows, enumerating icons, getting handles to icons, etc <= which is why -dt-'s script is seriously bloated IMHO):
To remove the icon:code:
function RemoveTrayIcon() {
var NIM_DELETE = 0x2;
var NOTIFYICONDATA = Interop.Allocate(88);
with (NOTIFYICONDATA) {
WriteDWORD(0, NOTIFYICONDATA.Size);
WriteDWORD(4, GetMSNHiddenWindowHandle());
WriteDWORD(8, 40046);
}
Interop.Call('shell32.dll', 'Shell_NotifyIconA', NIM_DELETE, NOTIFYICONDATA);
}
function GetMSNHiddenWindowHandle() {
var tIDCurrent = Interop.Call('Kernel32', 'GetCurrentThreadId');
var hWnd = 0;
while (hWnd = Interop.Call('User32', 'FindWindowExW', 0, hWnd, 'MSNHiddenWindowClass', 0))
if (Interop.Call('User32', 'GetWindowThreadProcessId', hWnd, 0) === tIDCurrent)
return hWnd;
}
to alter the tooltip, remove icon, readd icon, it is all similar and equally short... see attached script:
edit: change some lines