How to simulate mouse click with the WebBrowser control

。_饼干妹妹 提交于 2019-11-27 06:48:43

问题


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);

回答1:


Quite easily, simply use:

button.InvokeMember("click");


来源:https://stackoverflow.com/questions/5150610/how-to-simulate-mouse-click-with-the-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!