Finding and simulating a click on a system tray icon?

前端 未结 2 1295
轮回少年
轮回少年 2021-01-14 15:27

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

2条回答
  •  星月不相逢
    2021-01-14 16:24

    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.

    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.

提交回复
热议问题