开发者

How to discover the method that is called by a Windows Context Menu item?

开发者 https://www.devze.com 2023-01-14 09:17 出处:网络
When you click the right mouse button on your clean desktop it opens a context menu. Each item there is a call to a method.

When you click the right mouse button on your clean desktop it opens a context menu. Each item there is a call to a method. To programmatically call those methods, first I need to know which one I want. IIRC there is a tool that helps with that, but I can't remember it开发者_如何学编程s name.


You cannot call such a method in another process. You could try to inject the WM_COMMAND message that a context menu usually generates with SendMessage. Use Spy++ to find out what that message might be, if it exists.


Use Spy++ to find the handle and use SendMessage / PostMessage. It will be something similar to:

hwnd = FindWindow(...)
hmenu = GetMenu(hwnd)
hsubmenu = GetSubMenu(hmenu, 0)
menuid = GetMenuItem(hsubmenu, 1)
SendMessage(hwnd, WM_COMMAND, menuid, 0)
0

精彩评论

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

关注公众号