相关疑难解决方法(0)

是否有使用.NET的自动化测试示例源代码

是否有使用System.Windows.Automation进行软件自动化测试的源代码示例?

因为我真的有这个问题......

.net c# windows testing automation

5
推荐指数
1
解决办法
8366
查看次数

在c#中使用WINAPI单击消息框的"确定"按钮

我试图使用winapi单击C#窗体的消息框上的"确定"按钮.以下是我正在处理的代码.

private const int WM_CLOSE = 16;
private const int BN_CLICKED = 245;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);

[DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className,  string  windowTitle);

//this works
hwnd = FindWindow(null, "Message");
if(hwnd!=0)
      SendMessage(hwnd, WM_CLOSE, 0, IntPtr.Zero);

//this doesn't work.
hwndChild = FindWindowEx((IntPtr)hwnd, IntPtr.Zero, "Button", "ok");
SendMessage((int)hwndChild, BN_CLICKED, 0, IntPtr.Zero);
Run Code Online (Sandbox Code Playgroud)

虽然我得到了一个价值hwndChild,但它没有认识到BN_CLICKED.我不确定我错过了什么.任何帮助?

我试图关闭另一个应用程序的消息框按钮,这就是我正在做的事情.但是,我仍然缺少一些东西.

IntPtr hwndChild = IntPtr.Zero;
hwndChild = FindWindowEx((IntPtr)hwnd, …
Run Code Online (Sandbox Code Playgroud)

c# winapi messagebox

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×2

.net ×1

automation ×1

messagebox ×1

testing ×1

winapi ×1

windows ×1