Langage

AutomationElement.FromPoint(Point) Méthode

Définition

Récupère un nouvel AutomationElement objet pour l’élément d’interface utilisateur au point spécifié sur le bureau.

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

Paramètres

pt
Point

Coordonnées de l’écran physique sur le bureau à partir duquel localiser l’élément d’interface utilisateur.

Retours

Élément d’interface utilisateur au point spécifié.

Exemples

L’exemple suivant récupère l’emplacement AutomationElement du curseur système.

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

Remarques

FromPoint retourne l’élément dans l’arborescence logique la plus proche de l’élément racine.

Si votre application cliente peut essayer de trouver des éléments dans sa propre interface utilisateur, vous devez effectuer tous les appels UI Automation sur un thread distinct.

Bien que le point se trouve dans le rectangle englobant du rectangle retourné AutomationElement, il n’est pas nécessairement sur une partie cliquable du contrôle. Par exemple, un bouton rond peut ne pas être cliquable près de l’un des coins de son rectangle englobant.

S’applique à

Voir aussi