Finding and simulating a click on a system tray icon?

前端 未结 2 1296
轮回少年
轮回少年 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.

    0 讨论(0)
  • 2021-01-14 16:34

    See this MSDN Forum article which discusses how to find the systemTray's Handle. The article then references a CodeProject Article on how to find the handle of the application you are searching for. I have not tried this but it looks like it might be a viable starting point.

    0 讨论(0)
提交回复
热议问题