views:

554

answers:

1

The target app is written in Delphi (win32 not .NET) and is closed-source.

The action I want to invoke is called Copy, but there is no obvious keyboard shortcut. (Ctrl+Insert does the wrong thing and Ctrl+C does nothing)

I can find my target HWND and persuade it to open the context menu (it responds to WM_RBUTTONDOWN/UP not WM_CONTEXTMENU). From the menu HWND I can even obtain the menu handle via MN_GETHMENU and find the menu item I want. I just don't know the details of how to "choose" the item. It doesn't help that the menu is "modeless", ie. its HWND is not owned, so I don't know which of many hidden TPUtilWindow windows is the real owner - otherwise I could probably just send it a WM_COMMAND and not even pop up the menu, which would be preferable.

Although I am sure it facilitates all sorts of hacks, I would prefer not to inject code into the target process.

Answers accepted in any language.

+8  A: 

Apparently you're able to send it WM_RBUTTONDOWN/UP messages and it responds. If so, can you also send WM_KEYDOWN/UP messages? As long as you know the structure of the menu and it doesn't change, try telling the app that someone's pressing the Down arrow X number of times and then hitting ENTER. That seems like the simplest solution to me...

Mason Wheeler
Thanks, that worked, although for brevity I sent WM_CHAR not WM_KEYDOWN/UP.
Hugh Allen
Also, I just sent the accelerator key, not cursor down / enter.
Hugh Allen
OK, that works too. (You didn't mention if it had one.)
Mason Wheeler