C# 获取notifyIcons(托盘图标)上的文本

发布于 2024-08-18 07:49:47 字数 386 浏览 1 评论 0原文

我正在制作这个“你正在听的”插件,用于学习目的,将当前的 Spotify 或 Winamp 歌曲显示为 IM 客户端中的消息。

到目前为止,这非常简单,我只是像这样从标题中播放歌曲

Process.GetProcessesByName("spotify");

,然后选择歌曲部分(“Spotify - <歌曲标题>”)

proc.MainWindowTitle.Substring(10);

但是,大多数人不会保留主窗口打开或最小化到任务栏,但仅以托盘图标形式显示。我想从那里获取文本(将鼠标悬停在其上方时显示的文本)。

有什么简单的方法可以做到这一点吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2024-08-25 07:49:47

设置图标的工具提示文本需要使用 Shell_NotifyIcon() 和 NIM_UPDATE 消息,设置 NOTIFYICONDATA.szTip 成员。

最重要的是,如果您不拥有托盘图标,则无法找出需要使用的 hWnd 和 uID 值。 Windows 不支持枚举托盘图标。这也阻止了获取工具提示文本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文