WebBrowser对象 - 按位置获取元素

时间:2013-11-20 16:17:46

标签: c# webbrowser-control

我正在尝试按位置在c#webbrowser对象中获取元素。这可能吗?我已经能够用javascript做到这一点,但还没有找到这个问题的答案。

我已经找到了如何获得绝对位置,但没有找到如何根据实际位置实际选择项目。有什么想法吗?

编辑:

Position: X Y coordinates
Usecase: Selecting an input. And no I cannot rely on the id, name or dom order.

1 个答案:

答案 0 :(得分:1)

使用IHTMLDocument2::elementFromPoint,您可以通过任意点坐标获取元素。还有一些低级方法可能很有用:

  • IDisplayServices::CreateDisplayPointer
  • IDisplayServices::TransformPoint
  • IDisplayPointer::MoveToPoint
  • IDisplayPointer::GetFlowElement