当前位置:编程学习 > C#/ASP.NET >>

C#WebBrowser怎样模拟鼠标移动到指定链接

求大神帮帮忙 WebBrowser --------------------编程问答-------------------- 跪求大神 --------------------编程问答-------------------- WebBrowser可以直接取值,什么叫模拟鼠标移动到指定链接这个“动作”? --------------------编程问答--------------------
引用 2 楼 guwei4037 的回复:
WebBrowser可以直接取值,什么叫模拟鼠标移动到指定链接这个“动作”?



拿现在这个贴来说,在WebBrowser里把鼠标移动到这个位置上 --------------------编程问答-------------------- 通过webbrowser的htmlElement 你可以实现直接点击链接的动作 --------------------编程问答-------------------- 先在控件里获取到连接的位置,并转换为屏幕坐标,
然后

C# Win32API 模拟鼠标移动及点击事件
http://www.cnblogs.com/08shiyan/archive/2011/07/18/2109086.html

--------------------编程问答--------------------

HtmlElement html= webBrowser1.Document.GetElementById("id");
html.InvokeMember("click");
--------------------编程问答--------------------

HtmlElement password = webBrowser1.Document.All.GetElementsByName("password")[0];//通过name获取
                    password.InnerText = "456abc";
                    password.InvokeMember("click");
                    password.Focus();//有些页面给控件添加了Focus属性
 HtmlElement regemailinput = webBrowser1.Document.GetElementById("regemailinput");//通过ID获取
                     regemailinput.InvokeMember("click");
                    
--------------------编程问答-------------------- refer :
 private void Form1_Load(object sender, EventArgs e)
        {
            this.webBrowser1.Url = new Uri("http://www.baidu.com");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            HtmlElement searchWords = webBrowser1.Document.All["kw"];
            HtmlElement searchButton = webBrowser1.Document.All["su"];
            searchWords.SetAttribute("value", "guwei4037");
            searchButton.InvokeMember("click");
        }
--------------------编程问答-------------------- 如果页面有框架,可以这么做。


2
3
4
5
6
7
HtmlDocument htmlDoc = webBrowser1.Document.Window.Frames["mainFrame"].Document;
 
                if (htmlDoc != null)
                {
                    string qssj = htmlDoc.All["ajc10a"].GetAttribute("value");
                    string jssj = htmlDoc.All["ajc10b"].GetAttribute("value");
                }
--------------------编程问答-------------------- HtmlDocument 里面有个取元素的方法具体名字不记得的 --------------------编程问答-------------------- 6楼方法可行,LZ要做页游的模拟点击?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,