tags:

views:

475

answers:

2

What is the best way to programmatically restore and give focus to a third-party application (say, GoogleTalk or Twhirl) running in the system tray? I am writing my utility in C#, but I obviously have no control over the third-party application.

A: 

Use an API call to send mouse click events to the system tray? Google WM_SENDMSG SendMessage Win32 API for a starting point

There's also another API call for setting focus once the window's back up.

Josh W.
+3  A: 

Use something like FindWindow /FindWindowEx to find the hidden window and get its window handle and then call ShowWindow ( handle, SW_NORMAL) to unhide it.

Use a tool like Spy++ (can be found in the visual studio tools menu) to find the parameters which can be passed on to FindWindow to locate the desired window.

SDX2000
What if the hidden window has a Handle=0?
hawbsl
AFAIK a NULL handle represents an invalid HANDLE...FindWindow returns NULL when it fails in finding the specified window.
SDX2000