如何以编程方式选择另一个应用程序中的上下文菜单项?

发布于 2024-07-19 04:14:25 字数 569 浏览 1 评论 0原文

目标应用程序是用 Delphi(win32 而不是 .NET)编写的,并且是闭源的。

我想要调用的操作称为“复制”,但没有明显的键盘快捷键。 (Ctrl+Insert 做了错误的事情,Ctrl+C 什么也没做)

我可以找到我的目标 HWND 并说服它打开上下文菜单(它响应 WM_RBUTTONDOWN/UP不是WM_CONTEXTMENU)。 从菜单 HWND 中,我什至可以通过 MN_GETHMENU 获取菜单句柄并找到我想要的菜单项。 我只是不知道如何“选择”该项目的细节。 菜单是“无模式”的,这并没有帮助。 它的 HWND 不被拥有,所以我不知道许多隐藏的 TPUtilWindow 窗口中的哪一个是真正的所有者 - 否则我可能只是向它发送一个 WM_COMMAND< /code> 甚至不弹出菜单,这会更好。

尽管我确信它有助于各种黑客攻击,但我不希望将代码注入目标进程。

接受任何语言的答案。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡的优雅 2024-07-26 04:14:25

显然,您可以向其发送 WM_RBUTTONDOWN/UP 消息,并且它会做出响应。 如果是这样,您还可以发送 WM_KEYDOWN/UP 消息吗? 只要您知道菜单的结构并且它不会改变,请尝试告诉应用程序有人按了向下箭头 X 次,然后按 ENTER。 这对我来说似乎是最简单的解决方案......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文