views:

265

answers:

1

I'm crafting this "what you are listening to" - plugin for learning purposes that displays the current Spotify or Winamp song as a message in an IM client.

So far it's really simple, I'm merely getting the song played from the title like so

Process.GetProcessesByName("spotify");

and then just pick out the song part ("Spotify - < song title >")

proc.MainWindowTitle.Substring(10);

However, most people don't keep the main window open or minimized to the taskbar, but have it visible only as a tray icon. I'd like to get the text from there (the one displayed when hovering above it).

Is there any easy way of doing this?

Thanks

+3  A: 

Setting the tooltip text for the icon requires Shell_NotifyIcon() with the NIM_UPDATE message, setting the NOTIFYICONDATA.szTip member.

The showstopper is that you can't find out what hWnd and uID values you need to use if you don't own the tray icon. Windows doesn't support enumerating tray icons. Which also prevents getting the tooltip text.

Hans Passant