Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Kommentar
Den här dokumentationen System.Windows.Automation är avsedd för .NET Framework-utvecklare som vill använda de hanterade UI Automation-klasserna som definierats i namnområdet. Den senaste informationen om UI Automation finns i Windows Automation API: UI Automation.
Det här avsnittet visar hur du hämtar egenskaper för ett UI Automation-element.
Hämta ett aktuellt egenskapsvärde
Hämta den AutomationElement egendom som du vill få.
Anropa GetCurrentPropertyValueeller hämta egenskapsstrukturen Current och hämta värdet från en av dess medlemmar.
Hämta ett cachelagrat egenskapsvärde
Hämta den AutomationElement egendom som du vill få. Egenskapen måste ha angetts i CacheRequest.
Anropa GetCachedPropertyValueeller hämta egenskapsstrukturen Cached och hämta värdet från en av dess medlemmar.
Exempel
I följande exempel visas olika sätt att hämta aktuella egenskaper för en AutomationElement.
void PropertyCallsExample(AutomationElement elementList)
{
// The following two calls are equivalent.
string name = elementList.Current.Name;
name = elementList.GetCurrentPropertyValue(AutomationElement.NameProperty) as string;
// The following shows how to ignore the default property, which
// would probably be an empty string if the property is not supported.
// Passing "false" as the second parameter is equivalent to using the overload
// that does not have this parameter.
object help = elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, true);
if (help == AutomationElement.NotSupported)
{
help = "No help available";
}
string helpText = (string)help;
}
Sub PropertyCallsExample(ByVal elementList As AutomationElement)
' The following two calls are equivalent.
Dim name As String = elementList.Current.Name
name = CStr(elementList.GetCurrentPropertyValue(AutomationElement.NameProperty))
' The following shows how to ignore the default property, which
' would probably be an empty string if the property is not supported.
' Passing "false" as the second parameter is equivalent to using the overload
' that does not have this parameter.
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)
End Sub