C# WinAPI Clicking on menu items(C# WinAPI 单击菜单项)
问题描述
我试图点击名为 Media Subtitler 的程序中的菜单项,但无论我尝试做什么,它都不起作用.
I'm trying to click on a menu item inside a program called Media Subtitler and whatever I'm trying to do it's not working.
首先,我尝试使用函数 GetMenu 但它返回 IntPtr.Zero.然后,我尝试使用 ALT 键 + 使用菜单的第一个字母(F 代表文件),但它什么也没做.然后,我尝试使用简单的 MOUSEDOWN 和 MOUSEUP 消息,但同样,它什么也没做(我还尝试创建一个循环,点击该范围内的所有内容,但没有点击该区域).
First, I tried to use the function GetMenu but it returned IntPtr.Zero. Then, I tried using the ALT key + using the first letter of my menu (F stands for file) but it did nothing. Then, I tried using a simple MOUSEDOWN and MOUSEUP messages but again, it did nothing (I also tried creating a loop that clicks on everything in that range but there was no click in that area).
我清楚地知道我在正确的窗口上工作.
What I clearly know is that I'm working on the correct window.
我做错了什么?
如果有人想测试一下,您可以免费下载 Media Subtitler,它的重量并不大.
If someone wants to test it out you can download Media Subtitler for free and it doesn't weight that much.
另外,这是我一直在测试的代码:
Also, Here's the code I've been testing:
Process p = Process.Start(@"C:Program FilesDivXLandMedia SubtitlerMediaSub.exe");
p.WaitForInputIdle(1500);
Thread.Sleep(3000);
SetForegroundWindow(p.MainWindowHandle);
ShowWindow(p.MainWindowHandle, SW_MAXIMIZE);
IntPtr handle = p.MainWindowHandle;
SendMessage(handle, WM_NCHITTEST, 0, MakeLParam(18, 29));
//for (int i = 0; i < 200; i++)
//{
// for (int x = 0; x < 200; x++)
// {
// SendMessage(p.MainWindowHandle, WM_LBUTTONDOWN, 0, MakeLParam(i, x));
// SendMessage(p.MainWindowHandle, WM_LBUTTONUP, 0, MakeLParam(i, x));
// }
/
本文标题为:C# WinAPI 单击菜单项


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01