Share via


AutomationElement.FromPoint(Point) メソッド

定義

デスクトップ上の指定したポイントにあるユーザー インターフェイス (UI) 項目の新しい AutomationElement オブジェクトを取得します。

public:
 static System::Windows::Automation::AutomationElement ^ FromPoint(System::Windows::Point pt);
public static System.Windows.Automation.AutomationElement FromPoint (System.Windows.Point pt);
static member FromPoint : System.Windows.Point -> System.Windows.Automation.AutomationElement
Public Shared Function FromPoint (pt As Point) As AutomationElement

パラメーター

pt
Point

UI 要素を検索するデスクトップ上の物理画面座標。

戻り値

AutomationElement

指定したポイントにある UI 項目。

次の例では、システム カーソル位置 AutomationElement を取得します。

private AutomationElement ElementFromCursor()
{
    // Convert mouse position from System.Drawing.Point to System.Windows.Point.
    System.Windows.Point point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y);
    AutomationElement element = AutomationElement.FromPoint(point);
    return element;
}
Private Function ElementFromCursor() As AutomationElement
    ' Convert mouse position from System.Drawing.Point to System.Windows.Point.
    Dim cursorPoint As System.Windows.Point = New System.Windows.Point( _
        System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y)
    Return AutomationElement.FromPoint(cursorPoint)
End Function

注釈

FromPoint は、ルート要素に最も近い論理ツリー内の要素を返します。

クライアント アプリケーションが独自のユーザー インターフェイスで要素を検索しようとする場合は、別のスレッドですべてのUI オートメーション呼び出しを行う必要があります。

ポイントは返された AutomationElement四角形の外接範囲内にありますが、必ずしもコントロールのクリック可能な部分にあるとは限りません。 たとえば、丸いボタンは、外接する四角形の角の 1 つ付近でクリックできない場合があります。

適用対象

こちらもご覧ください