Shoutbox

Help: How to write code that hides system tray icon - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Help: How to write code that hides system tray icon (/showthread.php?tid=61971)

Help: How to write code that hides system tray icon by Black_Ice on 06-29-2006 at 02:08 AM

Hi All,
I was just wondering if anyone could help me out with some code that would hide (remove) the WLM icon from the taks bar. I want to write a script that will allow you to use a shortcut to hide the WLM icon...this will work hand in hand with MPL's Lock feature.

I can't find the code to hide the system tray icon anywhere! Any help would be greatly appreciated.

Cheers,
Black Ice


RE: Help: How to write code that hides system tray icon by rob_botch on 06-29-2006 at 09:33 AM

You probably wouldn't be able to do that with a script. You might be able to try patching a Messenger .dll file, but that is not recommended or allowed. Alternatively, you could cheat and make a transparent icon (or one that blends into the system tray) and set that as the icon on locking.

Hope that this helps


RE: Help: How to write code that hides system tray icon by Black_Ice on 06-29-2006 at 09:41 AM

Thanks for the reply.
Well how come you can get programs that hide the icon(s) of program(s) in the system tray? Aswell as hide the process in the Task Manager? Surely there is a way to do this, even if it's not in JScript. Like you said a DLL...here's a link to a similar plug-in for normal Messenger Plus!

http://360software.dakotabcn.net/umlock/index.html

This would allow you to hide msn's system tray icon with a shortcut.

I haven't given up yet because I know software can do this like...the ones at this page


RE: Help: How to write code that hides system tray icon by rob_botch on 06-29-2006 at 09:43 AM

Well.. perhaps you could use a script that runs one of these external programs, or another program with the capabilities to hide the icon. I would be very surprised if you could hide the icon directly from a script.


RE: Help: How to write code that hides system tray icon by Black_Ice on 06-29-2006 at 09:45 AM

Maybe not a script but a DLL or VB code


RE: Help: How to write code that hides system tray icon by rob_botch on 06-29-2006 at 09:46 AM

Yes, and then you could run this DLL or VB code from the script at certain points.


RE: Help: How to write code that hides system tray icon by Black_Ice on 06-29-2006 at 09:47 AM

Yup, only problem now is finding the right VB code...

Ok I'm really stuck, I've been searchin' for days. Does anyone know some VB 6 code that will allow me to hide another apps system tray icon (messenger live's icon).

Any help is greatly appreciated. Thanks in advance:)


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-13-2006 at 04:21 AM

Hey Black_Ice, i have found a partial solution to your problem. i myself used the Ultimate messenger lock alot, i can help you make the messenger icon dissappear, as in remove the icon but leave a space instead. go to the messenger plus! live preferences, click on the messenger tab, messenger lock. tick the checkbox that says "modify the systray icon" then click the icon, change the path to "C:\WINDOWS\system32\Shell32.dll,50" without the " and click ok. this will replace the messenger icon with a blank space every time you lock messenger. you might also want to disable the tooltip of the icon.


RE: Help: How to write code that hides system tray icon by matty on 08-13-2006 at 04:45 AM

Look please refrain from posting in threads where you do not know the correct answer.

This process is long and drawn out so I am not going to give you the exact code however I will tell you it is possible.

You need to basically get the handle of the icons and enumerate through them till you find the one relating to msnmsgr.exe. Once you find that you can (with some code) send NIM_DELETE to the icon and it will be removed.

http://support.microsoft.com/?scid=176085

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


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-13-2006 at 08:51 AM

Thanks I'lll give it ago and alert you of any success.


RE: RE: Help: How to write code that hides system tray icon by CookieRevised on 08-13-2006 at 09:26 PM

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
RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-14-2006 at 01:18 PM

how do use your script to hide the messenger icon when we lock messenger?


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-14-2006 at 09:40 PM

I'm working on that part but as of yet you can't. The code is just there but doesn't do anything yet.


RE: Help: How to write code that hides system tray icon by hmaster on 08-14-2006 at 10:04 PM

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 :)
RE: Help: How to write code that hides system tray icon by ecion on 08-14-2006 at 10:39 PM

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.


RE: Help: How to write code that hides system tray icon by matty on 08-15-2006 at 01:18 AM

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.
RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 07:59 AM

your script doesn't work. i want to remove the messenger icon and the space that it takes as well when i lock messenger.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 11:12 AM

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.


RE: Help: How to write code that hides system tray icon by CookieRevised on 08-15-2006 at 11:14 AM

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.
RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 11:42 AM

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.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 11:44 AM

You must add Matty's code to the end of the script (at the bottom).


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 11:45 AM

end of wat script?


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 11:47 AM

You must add Matty's code to the end of the script posted by cookie


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 11:48 AM

OOOOOOOHHH!! i was just putting matty's script there thanks alot well i suppose your problem is solved as well!


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 11:49 AM

Yup, no problem


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 12:00 PM

ok this isn't right. when i lock messenger the icon goes away then when i unlock it my icon doesn't come back, if i try locking it again it doesn't lock


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 12:03 PM

Have you disabled the "change icon to" (has a picture of networking icon). You can't have this enabled.


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-15-2006 at 12:04 PM

yes i have i also disabled the remove tooltip option

i think the problem might be in cookies script as matty has the

"function OnEvent_MessengerUnlocked(){
RestoreTrayIcon();
}"

part. i'm not so sure what cookies script does but i can make out mattys script says to remove the icon when messenger is locked and bing it back again when it is unlocked.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-15-2006 at 12:13 PM

You must Enable:
-Activate messenger lock with a system wide shorcut
-Change my status (option)
-Unlock with system wide shortcut

You must Disable:
-Modify tray Icon
-Disable tooltip and menu of system tray icon

Works for me. I don't use the password option but shouldn't make a difference


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-16-2006 at 08:12 AM

ok i really feel stupid now. i was copying and pasting cookies script instead of downloading the file. just a little note you don't need to enable the change status option if you don't want to.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-17-2006 at 10:56 AM

Ok my script WAS working...then I tried making an xml to go with it. I created a new .js file and then Plus! wouldn't let me run the script saying that it's either 'defective' or I have 'limited rights'. I'm sure there's something in my script that I've overlooked...:S Anyway I deleted the .js file and moved the xml file out of the directory I was using. So the script is back to how it was when it was working...only that it's not working!!

[Edit]
I made a new script just then and copied the code from the script that i've uploaded....it worked!?!? Yet still won't work in it's other form...
[/Edit]

Any help is much appreciated, I've attached what I have so far.


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-17-2006 at 11:06 AM

whoa, wats the problem the script works fine... just add mattys code to cookies code and it'll work fine.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-17-2006 at 11:07 AM

I've added other stuff to it


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-17-2006 at 11:10 AM

like wat?


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-17-2006 at 11:12 AM

Like making it revert back to ur status to what it was before it went into lock. Cause when mines in lock it changes my status to 'away' so when I use matty's and cookie's script...when I unlock it says my status is 'away'


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-17-2006 at 11:19 AM

anything else?


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-17-2006 at 11:20 AM

Not yet but will add in a later version:
-GUI window forcing those certain options to be enabled or disabled (for it to work)
-Remove messenger's process from task manager eg. msgmessenger.exe (or whateva it is)


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-17-2006 at 11:23 AM

k keep working on it but for now i think cookies and mattys script is enough for me. thanks for your effort Black_Ice, Matty and CookieRevised


RE: Help: How to write code that hides system tray icon by CookieRevised on 08-19-2006 at 09:12 AM

quote:
Originally posted by Black_Ice
Like making it revert back to ur status to what it was before it went into lock.
You shouldn't tamper with that as Plus! itself is responsible for setting and resetting your status when you lock/unlock messenger.

Also seeing your script, I really don't get why:
1) You use a timer to get the status 2 seconds after initialization and sign in. It makes no sense.
2) What you're trying todo with "var Status = DataBloc.ReadString(40);" DataBloc doesn't even exist in that function and it isn't declared anywhere
3) EDIT: "!===" isn't a valid comparisson operator.
4) EDIT: "False" isn't a valid boolean.

5) Don't change the comments I added. What you change it to is wrong:
quote:
your altered comments
// Just some helper function to get some icon
// Invisible window has a space in the system tray (like an invisible icon)
function GetMSNHiddenWindowIcon() {
The invisible window has not a space in the system tray:
1) the window will not add any space to the tray.
2) the window itself does have an icon. Which is exactly the whole point of that comment and that function.
So please leave the comments intact, or at least don't add wrong stuff:
quote:
original comments
// Just some helper function to get some icon
// (who knew that hidden window had an icon :) dodgy MS people adding an icon to an always invisible window :D)
function GetMSNHiddenWindowIcon() {



All you need is my code and implement it like Matty showed. Messenger Plus! itself will reset your status after an unlock anyways (if you have set it so to do this in the Plus! preferences).



------

To make a scriptpack there are some rules you need to apply to:
1) do not save your files in a subdirectory inside the zipfile (reason why your scriptpack doesn't work)
2) the scriptInfo.xml file must be in unicode (you did that) and need some basic xml headers (you didn't do that) <= this will not make your scriptpack not work, but it is not good practice what you did.

Read the information regarding scriptpacks in the Plus! Scripting Help file.
RE: Help: How to write code that hides system tray icon by Black_Ice on 08-19-2006 at 09:17 AM

Well you added in ur script:

code:
My.Status = My.Status


This keeps changing my status to 'away' after I come out of lock. During lock I have it set to go to 'away' but when I unlock it sets me as away and counts down from 15seconds...asking me if i'd like to personalise my status. Anyway I deleted this line in your code and all works well.

Guess it's no longer my script at all, you did it all.
RE: RE: Help: How to write code that hides system tray icon by CookieRevised on 08-19-2006 at 09:31 AM

quote:
Originally posted by Black_Ice
Well you added in ur script:

code:
My.Status = My.Status


This keeps changing my status to 'away' after I come out of lock. During lock I have it set to go to 'away' but when I unlock it sets me as away and counts down from 15seconds...asking me if i'd like to personalise my status. Anyway I deleted this line in your code and all works well.

Guess it's no longer my script at all, you did it all.

"My.Status = My.Status" will do nothing more then triggering messenger to update its icon again. It will actually not set a new status since the new status is the same as the old; it will just trigger the routine which messenger does when a status is changed (aka it sets a new icon in the tray). If you remove that line, the icon in the system tray will not be restored properly anymore.

A side effect can indeed be if you have the personalised status window set to popup when a status is set to "away", that it will popup too.

As the comment in the script suggested it is a simple 'trick'. The whole script is meant to show that hiding the tray icon (and tooltip) can be done extremely easy without the need of -dt-'s class. Hence why I also didn't added the events Matty showed. The script only has the bare essentials. The rest (like this trick) is simply added to have something more complete to test it with. It was never intended to be a total perfect script. For that, you need the icon handles from Messenger itself and restore the icon yourself with the API. The 'status=status' trick is just a shortcut.
RE: Help: How to write code that hides system tray icon by Black_Ice on 08-19-2006 at 09:47 AM

Well then the stuff I added was nessisary to fix that glitch up with the 'away' thing popping up.


RE: Help: How to write code that hides system tray icon by CookieRevised on 08-19-2006 at 10:35 AM

tbh, the stuff you added didn't fixed it and even wouldn't work (see first comment in my previous post here). simply removing the 'status=status' line is a way better fix (which works) for this.

But to 'fix' it in a proper way you have to make a function which catches the icon handles and set the tray icon to the proper icon using that same API.


RE: Help: How to write code that hides system tray icon by Black_Ice on 08-19-2006 at 10:41 AM

It works for me, what part doesn't work for you if I may ask?


RE: Help: How to write code that hides system tray icon by CookieRevised on 08-19-2006 at 11:52 AM

Everything you added to the script in this post. Which I explained why it doesn't work in this post.

What is posted there will not work with you either. It will not work for anyone as that altered and added code of yours is full of bugs and doesn't make much sense either.


Nothing personal, but why are people not reading posts properly? *sigh*


RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-19-2006 at 01:22 PM

Just a question i dont change my status when i lock messenger and i dont have that personalised status pop-up box enabled either. is there some glitch that i need to clear up in the script if i use these options? Another thing is there are these lines in cookies script

// Main stuff: Change the tooltip to whatever you want
function ChangeTooltip(newtext) {
// Create the datablock structure (v2)
var NOTIFYICONDATA = Interop.Allocate(488);
// Fill in some needed parameters
with (NOTIFYICONDATA) {
WriteDWORD(0, NOTIFYICONDATA.Size); //DWORD cbSize
WriteDWORD(4, GetMSNHiddenWindowHandle()); //HWND  hWnd
WriteDWORD(8, 40046); //UINT  uID
WriteDWORD(12, NIF_TIP); //UINT  uFlags
WriteString(24, newtext.substring(0, 127), false); //WCHAR szTip[128]

it says change the tooltip to whatever you want, what if i dont want to change it, do I leave it as it is? It also says to fill in some needed parameters, what do i need to fill in and how do i do it. if there is also some other manual editing i need to do plz can you tell me. i am a total newbie to scripting but i get the general idea most of the time.


RE: RE: Help: How to write code that hides system tray icon by CookieRevised on 08-19-2006 at 01:47 PM

quote:
Originally posted by shrav/oo7`
Just a question i dont change my status when i lock messenger and i dont have that personalised status pop-up box enabled either. is there some glitch that i need to clear up in the script if i use these options?
READ the thread and the posts, all that has just been explained in previous 10 (or so) posts...

quote:
Originally posted by shrav/oo7`
Another thing is there are these lines in cookies script

// Main stuff: Change the tooltip to whatever you want
function ChangeTooltip(newtext) {
// Create the datablock structure (v2)
var NOTIFYICONDATA = Interop.Allocate(488);
// Fill in some needed parameters
with (NOTIFYICONDATA) {
WriteDWORD(0, NOTIFYICONDATA.Size); //DWORD cbSize
WriteDWORD(4, GetMSNHiddenWindowHandle()); //HWND  hWnd
WriteDWORD(8, 40046); //UINT  uID
WriteDWORD(12, NIF_TIP); //UINT  uFlags
WriteString(24, newtext.substring(0, 127), false); //WCHAR szTip[128]

it says change the tooltip to whatever you want, what if i dont want to change it
You don't use that function....

That function is to change the tooltip, if you don't want to change the tooltip, don't use that function :/

quote:
Originally posted by shrav/oo7`
It also says to fill in some needed parameters, what do i need to fill in and how do i do it.
Comments explain what is being done. If it says fill in some stuff it means the next lines will fill in some stuff.

quote:
Originally posted by shrav/oo7`
i am a total newbie to scripting but i get the general idea most of the time.
tbh, don't attempt to alter anything.

I don't want to be rude or anything but seeing your previous posts and stuff you first need to learn the basics of scripting and all (and also read posts more carefully). If you don't understand stuff don't use it... Sorry, but explaning every bit and angle of scripting and why something is done in this particular script and all without you understanding even the basics is seriously out of scope.
RE: Help: How to write code that hides system tray icon by shrav/oo7` on 08-19-2006 at 01:53 PM

yeah i know i don't really know anything about scripting. well i suppose i should be fine as i am, i don't need to alter anything.


RE: Help: How to write code that hides system tray icon by Black_Ice on 01-22-2007 at 01:00 PM

Cookie, or anyone else for that matter...
It appears the code posted by Cookie will remove WLM icon but on unlock WLM crashes with a custom-like "report error to microsoft message." Can anyone confirm this? I'm using:

WLM Version: 8.0.0812.00
MP!L Version: 4.11.0.254

I have a hunch that it's WLM (hope this isn't a permanent problem! Wonder if it works in 8.1 Beta...) just wondering if anyone else has the same issues?

Thanks.