UWP应用程序中的AutomationElement

时间:2017-01-04 09:14:33

标签: c# winapi uwp ui-automation

我正在UWP应用程序中进行UI自动化的一些实验,我想知道是否可以在UWP应用程序中使用以下代码(Getting a Handle to a button in another window)。

var hwnd = FindWindowByCaption((IntPtr)0, "App1");

AutomationElement lync = AutomationElement.FromHandle(hwnd);
AutomationElement optionsButton = lync.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "something"));
((InvokePattern)optionsButton.GetCurrentPattern(InvokePattern.Pattern)).Invoke();

如果我为我的UWP项目添加“正确”引用

  • UIAutomationClient
  • UIAutomationTypes

我收到了以下错误。

Cannot find type System.SystemException in module CommonLanguageRuntimeLibrary.

我完全理解我不能这样做(将这些引用添加到UWP项目中)。有没有其他可能的方法如何做或不可能?

1 个答案:

答案 0 :(得分:1)

UWP模型中应用程序的沙盒意味着这是不可能的。

如果您有充分理由需要这样做,请在https://wpdev.uservoice.com/

上提出建议(理由是需要它 - 这有助于您提高说服力)