Help: How to write code that hides system tray icon |
Author: |
Message: |
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: RE: Help: How to write code that hides system tray icon
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
Attachment: TrayIcon Manipulation.plsc (2.02 KB)
This file has been downloaded 280 time(s).
This post was edited on 03-06-2007 at 01:15 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-13-2006 09:26 PM |
|
|
shrav/oo7`
Junior Member
Posts: 22
34 / / –
Joined: Aug 2006
|
RE: Help: How to write code that hides system tray icon
how do use your script to hide the messenger icon when we lock messenger?
This post was edited on 08-14-2006 at 01:21 PM by shrav/oo7`.
|
|
08-14-2006 01:18 PM |
|
|
Black_Ice
Junior Member
Posts: 26
34 / / –
Joined: Jun 2006
|
O.P. RE: Help: How to write code that hides system tray icon
I'm working on that part but as of yet you can't. The code is just there but doesn't do anything yet.
|
|
08-14-2006 09:40 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: Help: How to write code that hides system tray icon
quote: Originally posted by shrav/oo7`
how do use your script to hide the messenger icon when we lock messenger?
In the Plus! options just change the icon to one of the system icons
But it would be cool to be able to hide it completely and have a shortcut to reopen
This post was edited on 08-14-2006 at 10:06 PM by hmaster.
|
|
08-14-2006 10:04 PM |
|
|
ecion
Junior Member
Posts: 25 Reputation: -1
37 / / –
Joined: Jul 2004
|
RE: Help: How to write code that hides system tray icon
sorry if this is slightly off topic, but can other icons within Messenger be altered too? for example the the icon that appears in the very top-left corner of a chat window, along with icon displayed in the task bar when a chat is open? - Just wondering if they could be altered to the 'away/busy' icons when your contact is set to that status, could be quite useful.
|
|
08-14-2006 10:39 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Help: How to write code that hides system tray icon
quote: Originally posted by shrav/oo7`
how do use your script to hide the messenger icon when we lock messenger?
code: function OnEvent_MessengerLocked(){
RemoveTrayIcon();
}
function OnEvent_MessengerUnlocked(){
RestoreTrayIcon();
}
However doing this will cause you not to be able to get out of Messenger Lock unless you have a global shortcut to unlock it.
|
|
08-15-2006 01:18 AM |
|
|
shrav/oo7`
Junior Member
Posts: 22
34 / / –
Joined: Aug 2006
|
RE: Help: How to write code that hides system tray icon
your script doesn't work. i want to remove the messenger icon and the space that it takes as well when i lock messenger.
|
|
08-15-2006 07:59 AM |
|
|
Black_Ice
Junior Member
Posts: 26
34 / / –
Joined: Jun 2006
|
O.P. RE: Help: How to write code that hides system tray icon
You won't be able to unlock it unless you use a different key combination like matty mentioned.
quote: However doing this will cause you not to be able to get out of Messenger Lock unless you have a global shortcut to unlock it.
This post was edited on 08-15-2006 at 11:13 AM by Black_Ice.
|
|
08-15-2006 11:12 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Help: How to write code that hides system tray icon
quote: Originally posted by shrav/oo7`
your script doesn't work. i want to remove the messenger icon and the space that it takes as well when i lock messenger.
add the two functions Matty showed. It works perfectly.
PS: since Plus! can also change the icon, the only problem you may encounter is when you unlock messenger again since Plus! expects there to be an icon. Since it is not there Messenger might crash. Simply don't change the icon (untick that option in the preferences of messenger lock in Plus!) when you want it to be removed.
quote: Originally posted by Black_Ice
You won't be able to unlock it unless you use a different key combination like matty mentioned.
this has got nothing todo with the script or issue. Even without the script and any icon manipulation, you wont be able to use the same shortcut to lock and unlock; that's a basic (and understandeable) limitation of Plus!.
However, what Matty said is something entirly else. He said that you wont be able to unlock messenger when you have choosen the option to double click on the system tray icon to unlock messenger. Very logical, since there isn't a tray icon anymore with this script, you also wont be able to double click on it. The only way to unlock messenger in that case is by using a shortcut.
This post was edited on 08-15-2006 at 11:17 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-15-2006 11:14 AM |
|
|
shrav/oo7`
Junior Member
Posts: 22
34 / / –
Joined: Aug 2006
|
RE: Help: How to write code that hides system tray icon
it still doesnt work. just to make sure, i have to go to the MP! L preferences click on the scripts tab and create a new one, then i have to add matty's script over there and save it. i should then be able to lock messenger using my shortcut which is ctrl+space and the icon should disappear as well as the space. i should then be able to unlock messsenger using my unlock shortcut which is ctrl+alt+space, then i type in my messenger lock password and messenger should open up. i have unticked the option to modify the system icon like CookieRevised suggested.
|
|
08-15-2006 11:42 AM |
|
|
Pages: (5):
« First
«
1
[ 2 ]
3
4
5
»
Last »
|
|