以编程方式查找消息框并单击按钮 [英] Programatically finding a message box and generating a click on a button

查看:27
本文介绍了以编程方式查找消息框并单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动测试 winform 应用程序.我在与测试代码相同的进程中运行它,因此很容易找到 .Net 控件并模拟用户对它们的操作.然而,我被一个消息框(使用标准 MessageBox.Show 方法创建)卡住了.我怎样才能抓住它并模拟按下按钮?

I am trying to automate testing of a winform application. I am running it in the same process as the test code, so it is fairly easy to find the .Net controls and simulate user action on them. I got however stuck a bit with a message box (created using the standard MessageBox.Show method). How can I get hold of it and simulate that a button is pressed?

推荐答案

您可能必须使用 WinAPI 调用(FindWindowEx 等)并将 LMB 消息向下和向上发送到按钮句柄.

You probably will have to use WinAPI calls (FindWindowEx, ect) and send a messages of LMB down and up to a button handle.

这篇关于以编程方式查找消息框并单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆