查找并模拟系统托盘图标上的点击? [英] Finding and simulating a click on a system tray icon?

查看:442
本文介绍了查找并模拟系统托盘图标上的点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要弄清楚如何以编程方式从单独的应用程序的系统托盘图标中查找和选择上下文菜单项。我能想象的完成这一点的唯一方法是使用mouse_event()与一些硬编码的x / y值,并将图标设置为始终显示。除了一般的硬编码的黑客使用,这里的问题是假设图标将保留它的位置(这可能会破坏任何时间另一个应用程序加载/卸载)。

I need to figure out how to programmatically find and select a context menu item from a separate application's system tray icon. The only way I could imagine accomplishing this was to use mouse_event() with some hard-coded x/y values, and set the icon to always be shown. Aside from the hacky use of hard-coding in general, the problem here is the assumption that the icon will retain it's position (which is likely to break any time another application loads/unloads). I was wondering if anybody knew any other way to go about this?

推荐答案

根据应用程序的写入方式,选择项从上下文菜单将导致 WM_COMMAND 消息发布到属于应用程序的窗口。你可以使用像Spy ++这样的工具来检查这个。

Depending on how the application has been written, selecting the item from the context menu will cause a WM_COMMAND message to be posted to a window belonging to the application. You can use a tool like Spy++ to check for this. If this is the case then all you would have to do (in theory) is simulate that message.

如果应用程序不使用 WM_COMMAND

If the application does not use WM_COMMAND to receive selections from the context menu, your job is much harder. There is no documented method of discovering the position and identify of system tray items, and so your method of hard-coding the x/y values is probably the best option you have.

这篇关于查找并模拟系统托盘图标上的点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆