フォーカスされたAutomationElement(ポイント)でテキストを検索するパフォーマンスを向上させる方法を探しています。私はすでにこのようなコードを持っています。UIAComWrapperを使用しており、かなり低速です。
public static string GetValueFromNativeElementFromPoint(Point p)
{
var element = UIAComWrapper::System.Windows.Automation.AutomationElement.FromPoint(p);
var pattern =
((UIAComWrapper::System.Windows.Automation.LegacyIAccessiblePattern)
element.GetCurrentPattern(UIAComWrapper::System.Windows.Automation.LegacyIAccessiblePattern.Pattern));
return pattern.Current.Value;
}
解決策が見つかりました。UIAComWrapperを使用した場合の2秒と7秒。
public static string GetValueFromNativeElementFromPoint2(Point p)
{
var element = AutomationElement.FromPoint(p);
object patternObj;
if (element.TryGetCurrentPattern(ValuePattern.Pattern, out patternObj))
{
var valuePattern = (ValuePattern) patternObj;
return valuePattern.Current.Value;
}
return null;
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加