c# winform WebBrower 控件中右键获取控件坐标
加载页面以后,鼠标右键时候,自动生成事件 (加载右键事件)获取坐标,
当点击左键的时候,获取 图片链接
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown);
}
void Document_MouseDown(object sender, HtmlElementEventArgs e)
{
if (e.MouseButtonsPressed == MouseButtons.Right)
{
Console.WriteLine(e.MousePosition);
}
else if (e.MouseButtonsPressed == MouseButtons.Left)
{
HtmlElement ele = webBrowser1.Document.GetElementFromPoint(e.MousePosition);
if (ele!= null)
{
Console.WriteLine(ele.GetAttribute("href"));
}
}
}