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 单击菜单项
基础教程推荐
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 将数据集转换为列表 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 如果条件可以为空 2022-01-01
