如何模拟鼠标点击使用WebBrowser控件 [英] How to simulate mouse click with the WebBrowser control

查看:739
本文介绍了如何模拟鼠标点击使用WebBrowser控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 web浏览器控制,我能够调用一个事件,当鼠标按钮手动点击,但我想要的程序做单击本身,而不是做一些事情的时候我手动执行的点击。

例如,如果我提供我想要的页面上的控件的ID的程序,请单击它。

这是我到目前为止有:

 的HtmlElement按钮= webBrowser1.Document.GetElementById(lButtonSearch);
button.Click + =新HtmlElementEventHandler(GotoSearchPage);
 

解决方案

很容易,只需使用:

  button.InvokeMember(点击);
 

Using the WebBrowser control I am able to call an event when the mouse button is manually clicked, but I want the program to do the click itself, not do something when I manually perform the click.

For example, if I provide the ID of a control on the page I want the program to click it.

Here's what I have so far:

HtmlElement button = webBrowser1.Document.GetElementById("lButtonSearch");
button.Click += new HtmlElementEventHandler(GotoSearchPage);

解决方案

Quite easily, simply use:

button.InvokeMember("click");

这篇关于如何模拟鼠标点击使用WebBrowser控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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