AutomationElement.FromPoint(Point) Methode

Definition

Ruft ein neues AutomationElement Objekt für das Benutzeroberflächenelement (UI) am angegebenen Punkt auf dem Desktop ab.

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

Parameter

pt
Point

Die physischen Bildschirmkoordinaten auf dem Desktop, bei denen das UI-Element gefunden werden soll.

Gibt zurück

AutomationElement

Das UI-Element an dem angegebenen Punkt.

Beispiele

Im folgenden Beispiel wird der AutomationElement Systemcursorspeicherort abgerufen.

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

Hinweise

FromPoint gibt das Element in der logischen Struktur zurück, die dem Stammelement am nächsten ist.

Wenn Ihre Clientanwendung möglicherweise versucht, Elemente in einer eigenen Benutzeroberfläche zu finden, müssen Sie alle Benutzeroberflächenautomatisierung Aufrufe auf einem separaten Thread vornehmen.

Obwohl der Punkt innerhalb des gebundenen Rechtecks des zurückgegebenen AutomationElementSteuerelements liegt, ist es nicht unbedingt auf einem klickbaren Teil des Steuerelements. Beispielsweise kann eine runde Schaltfläche möglicherweise nicht in der Nähe einer der Ecken des gebundenen Rechtecks geklickt werden.

Gilt für

Siehe auch