求帮忙解决剩下2个写程软件按钮句柄抓取,要求达>看图片前面两个我自己写的,我可以提供软件包和我自己工程文件
有意愿的可以留言我
这是ST的(已完成)
这是瑞萨的(已完成)
按钮和界面一体拿不到句柄说明界面用的不是win原生控件制作,
有可能是qt或者其他directUI框架制作的,
可以先计算出按钮相对于客户区域的坐标,然后给主窗口发送鼠标点击事件带上相对坐标
能拿到按钮句柄,发送点击事件没有响应,
1 有可能是程序判断了当前窗口是不是在最前端,没在最前端就不处理
2 有可能程序获取鼠标的当前坐标,判断是不是在按钮上面,没在按钮上面不处理
测试下, 用一个定时器延迟下发送消息,然后将要点击的窗口处于最前端,然后将鼠标移动到按钮上看看有没有响应消息
可直接给按钮的父窗口发送 wm_command 消息 ,一般按钮被点击都是给父窗口发送 wm_command ,父窗口统一处理按钮点击事件
你是想读取软件下面的提示信息吗?软件发我试下
以下是针对瑞萨的软件按钮句柄抓取的示例代码,可以参考实现:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ButtonHandleCapture
{
class Program
{
// 定义 FindWindowEx 和 SendMessage 函数
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
static void Main(string[] args)
{
// 设置瑞萨软件窗口的类名和窗口名
string className = "WindowsForms10.Window.8.app.0.33c0d9d";
string windowName = "CubeSuite+ for RL78 (RL78/G13)";
// 找到瑞萨软件的主窗口句柄
IntPtr mainWindowHandle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, className, windowName);
if (mainWindowHandle == IntPtr.Zero)
{
Console.WriteLine("未找到窗口句柄");
return;
}
// 根据窗口句柄找到 Button 控件的父窗口句柄
IntPtr buttonParentHandle = FindWindowEx(mainWindowHandle, IntPtr.Zero, "MDIClient", null);
buttonParentHandle = FindWindowEx(buttonParentHandle, IntPtr.Zero, "WindowsForms10.Window.8.app.0.33c0d9d", null);
if (buttonParentHandle == IntPtr.Zero)
{
Console.WriteLine("未找到按钮父窗口句柄");
return;
}
// 根据父窗口句柄和控件名称找到按钮控件句柄
IntPtr buttonHandle = FindWindowEx(buttonParentHandle, IntPtr.Zero, "WindowsForms10.BUTTON.app.0.33c0d9d", "下载程序");
if (buttonHandle == IntPtr.Zero)
{
Console.WriteLine("未找到按钮句柄");
return;
}
// 输出按钮句柄
Console.WriteLine("瑞萨下载程序按钮句柄为:" + buttonHandle.ToString());
}
}
}
上述代码使用了 FindWindowEx 函数和 SendMessage 函数,其中 FindWindowEx 函数用于查找窗口和控件句柄,SendMessage 函数用于向窗口发送消息,例如点击按钮等操作。这里只演示了如何获取按钮句柄,具体的按钮操作可以参考相关文档。
参考gpt
实现的第三方程序嵌入自己的WinForm
借鉴下
https://blog.csdn.net/qq_36447261/article/details/103059168