Jakub Krampl
Jakub Krampl

Reputation: 1794

AutomationElement in UWP apps

I am doing some experiments with UI Automation in UWP apps and I wonder, whether is possible to use following code in UWP app (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();

If I add "correct" references to my UWP project

I am getting following error.

Cannot find type System.SystemException in module CommonLanguageRuntimeLibrary.

I completely understand that I simply cannot do it this way (adding those references to UWP projects). Is there any other possible way how to do it or is it impossible?

Upvotes: 0

Views: 615

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 65586

The sandboxing of apps in the UWP model means that this isn't possible.

If you have a strong reason for needing to do this then make a suggestion (with your reason for needing it--it helps you be more persuasive) on https://wpdev.uservoice.com/

Upvotes: 1

Related Questions