🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by nicolasr Tue, 11 Dec 2007 03:15
How to remove dead system tray icons
#860
Author: nicolasr
Date: Tue, 11 Dec 2007 03:15
40 lines
2384 bytes
Hi all,

I have a third party application (app1) that I need to automate.
My controller app (app2) starts app1 and watches
at certain intervals whether app1 is still alive.
Every now and then app1 crashes, needs to
automatically be terminated and restarted.
(Unfortunately I don't have source code for app1
to correct the actual problem....)

This works as expected except for the fact that
app1 has a tray icon and after app1 has been
terminated and restarted several times the tray
area expands over the entire task bar and
displays dead tray icons of app1 that would
disappear if I moved over them with the mouse.
Unfortunately nobody sits in front of the PC and all
this needs to be automated. So app2 should be able
to remove those dead icons.

I found some code like:

HWND hTaskbar = FindWindow("Shell_TrayWnd", NULL);
HWND hSysTray = FindWindowEx(hTaskbar, 0, "TrayNotifyWnd", NULL);
RECT rect;
GetWindowRect(hSysTray, &rect);

that then uses mouse_event() to simulate a user moving the mouse
over the system tray. While this works on my XP machine with one dead icon
it does not work reliably on the business W2K machine with other things 
running
concurrently.

Does anyone have any ideas how to do this?

How about sending mouse messages directly to the sys tray window?
Or any other way to force explorer to update the system tray?

thanks for any idea.
Nick
Re: How to remove dead system tray icons
#861
Author: Dennis Jones
Date: Tue, 11 Dec 2007 07:24
45 lines
2649 bytes
"nicolasr" <nicolasrREMOVETHISSPAMBLOCKER@gmx.net> wrote in message 
news:475e00d0$1@newsgroups.borland.com...
> Hi all,
>
> I have a third party application (app1) that I need to automate.
> My controller app (app2) starts app1 and watches
> at certain intervals whether app1 is still alive.
> Every now and then app1 crashes, needs to
> automatically be terminated and restarted.
> (Unfortunately I don't have source code for app1
> to correct the actual problem....)
>
> This works as expected except for the fact that
> app1 has a tray icon and after app1 has been
> terminated and restarted several times the tray
> area expands over the entire task bar and
> displays dead tray icons of app1 that would
> disappear if I moved over them with the mouse.
> Unfortunately nobody sits in front of the PC and all
> this needs to be automated. So app2 should be able
> to remove those dead icons.
>
> I found some code like:
>
> HWND hTaskbar = FindWindow("Shell_TrayWnd", NULL);
> HWND hSysTray = FindWindowEx(hTaskbar, 0, "TrayNotifyWnd", NULL);
> RECT rect;
> GetWindowRect(hSysTray, &rect);
>
> that then uses mouse_event() to simulate a user moving the mouse
> over the system tray. While this works on my XP machine with one dead icon
> it does not work reliably on the business W2K machine with other things 
> running
> concurrently.
>
> Does anyone have any ideas how to do this?
>
> How about sending mouse messages directly to the sys tray window?
> Or any other way to force explorer to update the system tray?

I've posted a demo utility in the attachments group.  Try it out and see if 
it does what you want.

- Dennis 
Re: How to remove dead system tray icons
#908
Author: nicolasr
Date: Tue, 11 Dec 2007 20:15
15 lines
1605 bytes
Hi and thanks for your response.
On my local system your demo works but I need to automate it
on a network machine and run it for a couple of days.
If you could send me the DLL version I would be very grateful.
My email is
nicolasrREMOVETHISSPAMBLOCKER@gmx.net

thanks,
Nick

> I've posted a demo utility in the attachments group.  Try it out and see 
> if it does what you want.
>
> - Dennis
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads