Breyta

Deila með


AutomationElement.GetCurrentPropertyValue Method

Definition

Retrieves the current value of the specified property from an AutomationElement.

Overloads

GetCurrentPropertyValue(AutomationProperty)

Retrieves the value of the specified property on this AutomationElement. An appropriate default value for the property type is returned for properties not explicitly supported by the target user interface (UI) element.

GetCurrentPropertyValue(AutomationProperty, Boolean)

Retrieves the value of the specified property on this AutomationElement, optionally ignoring any default property.

Remarks

The value returned by the GetCurrentPropertyValue method is current at the time it is called. The value can subsequently change by other applications interacting with the user interface (UI).

For some forms of UI, this method will incur cross-process performance overhead. Applications can concentrate overhead by caching properties and then retrieving them by using GetCachedPropertyValue.

GetCurrentPropertyValue(AutomationProperty)

Retrieves the value of the specified property on this AutomationElement. An appropriate default value for the property type is returned for properties not explicitly supported by the target user interface (UI) element.

public:
 System::Object ^ GetCurrentPropertyValue(System::Windows::Automation::AutomationProperty ^ property);
public object GetCurrentPropertyValue (System.Windows.Automation.AutomationProperty property);
member this.GetCurrentPropertyValue : System.Windows.Automation.AutomationProperty -> obj
Public Function GetCurrentPropertyValue (property As AutomationProperty) As Object

Parameters

property
AutomationProperty

The UI Automation property identifier specifying which property to retrieve.

Returns

An object containing the value of the specified property.

Exceptions

The UI for the AutomationElement no longer exists.

Examples

The following example retrieves the current value of the HelpText property. The default value is returned if the element does not provide one.

// elementList is an AutomationElement.
string helpString =
    elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty) as string;
' elementList is an AutomationElement.
Dim helpString As String = _
    CStr(elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty))

Remarks

The value returned by the GetCurrentPropertyValue method is current at the time it is called. The value can subsequently change by other applications interacting with the UI.

If the UI Automation provider for the element itself supports the property, the value of the property is returned. Otherwise, a default property specified by UI Automation is returned. For information on default properties, see the property identifier fields of AutomationElement, such as AcceleratorKeyProperty.

For some forms of UI, this method will incur cross-process performance overhead. Concentrate overhead by caching properties and then retrieving them by using GetCachedPropertyValue.

Applies to

GetCurrentPropertyValue(AutomationProperty, Boolean)

Retrieves the value of the specified property on this AutomationElement, optionally ignoring any default property.

public:
 System::Object ^ GetCurrentPropertyValue(System::Windows::Automation::AutomationProperty ^ property, bool ignoreDefaultValue);
public object GetCurrentPropertyValue (System.Windows.Automation.AutomationProperty property, bool ignoreDefaultValue);
member this.GetCurrentPropertyValue : System.Windows.Automation.AutomationProperty * bool -> obj
Public Function GetCurrentPropertyValue (property As AutomationProperty, ignoreDefaultValue As Boolean) As Object

Parameters

property
AutomationProperty

The UI Automation property identifier specifying which property to retrieve.

ignoreDefaultValue
Boolean

A value that specifies whether a default value should be ignored if the specified property is supported.

Returns

An object containing the value of the specified property, or NotSupported if the element does not supply a value and ignoreDefaultValue is true.

Exceptions

The UI for the AutomationElement no longer exists.

Examples

The following example retrieves the current value of the HelpText property, but specifies that if the element itself does not provide a value for the property, NotSupported is to be returned instead of a default value.

// elementList is an AutomationElement.
object help = elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, true);
if (help == AutomationElement.NotSupported)
{
    help = "No help available";
}
string helpText = (string)help;
' elementList is an AutomationElement.
Dim help As Object = elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, True)
If help Is AutomationElement.NotSupported Then
    help = "No help available"
End If
Dim helpText As String = CStr(help)

Remarks

Passing false in ignoreDefaultValue is equivalent to calling AutomationElement.GetCurrentPropertyValue(AutomationProperty).

If the UI Automation provider for the element itself supports the property, the value of the property is returned. Otherwise, if ignoreDefaultValue is false, a default property specified by UI Automation is returned. For information on default properties, see the property identifier fields of AutomationElement, such as AcceleratorKeyProperty.

The value returned by the GetCurrentPropertyValue method is current at the time it is called. The value can subsequently change by other applications interacting with the user interface (UI).

For some forms of UI, this method will incur cross-process performance overhead. Applications can concentrate overhead by caching properties and then retrieving them by using GetCachedPropertyValue.

Applies to