How to programmatically select a context menu item in another application?

The target application is written in Delphi (win32 is not .NET) and is closed.

The action I want to call is called Copy, but there is no obvious key combination. (Ctrl + Insert does the wrong thing, but Ctrl + C does nothing)

I can find my goal HWNDand convince her to open the context menu (it responds to WM_RBUTTONDOWN/UPnot WM_CONTEXTMENU). From the menu, HWNDI can even get the menu handle through MN_GETHMENUand find the menu item that I want. I just don’t know the details of how to “select” an element. It does not help that the menu is "weak", i.e. it HWNDdoesn’t belong, so I don’t know which of the many hidden windows TPUtilWindowis the real owner, otherwise I could just send it WM_COMMANDand not even jump into the menu, which would be preferable.

Although I am sure that this facilitates all kinds of hacks, I would prefer not to enter the code into the target process.

Answers accepted in any language.

+5
source share
1 answer

Apparently, you can send him messages WM_RBUTTONDOWN/UP, and he answers. If so, can you also send messages WM_KEYDOWN/UP? As long as you know the structure of the menu and do not change, try to tell the application that someone presses the down arrow X, and then press ENTER. This seems like the easiest solution for me ...

+8
source

All Articles