简体   繁体   中英

How to detect changes to the Windows system tray?

I've got a Windows 7 VM which runs my mandatory corporate communication systems (Lync and Outlook). What I'd like to do is run a process on this Windows machine which monitors the system tray and sends notifications to my host machine (Xubuntu 13.04) so I'm informed when I get an email or IM (I've already tried seamless RDP to do this but it's an ineffective solution).

Anything Linux or network oriented I can handle with relative ease, what I do not know how to do is to how to query the state of the Windows system tray (or attach an event listener for state changes). I'm comfortable with C++ and Python but I'll give any viable solution a go.

Detailed state information would be preferable but at the very minimum I need to be able to detect changes in the number of icons in the tray.

On Windows, if you install Visual Studio, among Visual Studio Tools there is a useful tool, named "Spy++", basically it's a tool that shows you all the windows and gives ability to see what messages particular window receives.

在此处输入图片说明

Using this tool, you can see that whole panel, that contains "Start button", shortcuts, tray, clock, etc. is "Shell_TrayWnd". You can use "Find" menu to search for a particular window just dragging an "aim" on any window.

The tray window itself is "SysPager" (000100D2 on attached image), you can log messages for this window and see what type of message this window receives when you receive mail in Outlook.

After that you can write a code that will listen to all messages that this window receives, and basing on what you have seen in "Spy++" determine what happened.

This is just for start. Writing a code that will get a window handle and listen to messages that window receives is another part, but I think it's already covered at MSDN or even at StackOverflow. Searching for a particular window handle is done by FindWindowEx function and in order to listen to message you have to set a "hook" that is done by SetWindowsHookEx function. Hooking is described pretty good on MSDN.

may be you need Outlook inspector ( http://msdn.microsoft.com/en-us/library/office/ff869356(v=office.15).aspx ). As i understand it helps to watch events outlook processes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM