C# Getting the text off notifyIcons (tray icons)
Asked Answered
C

1

8

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

Chromatography answered 17/1, 2010 at 16:19 Comment(0)
A
4

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.

Ante answered 17/1, 2010 at 16:44 Comment(1)
Actually you can enumerate them: codeproject.com/KB/applications/ShellTrayInfo.aspxGehlbach

© 2022 - 2024 — McMap. All rights reserved.