开发者

C# Getting the text off notifyIcons (tray icons)

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 eas开发者_如何学Pythony way of doing this?

Thanks


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜