private UIObject LaunchUWPApp(string packageName) { Debug.Assert(_isUWPApp); var nameCondition = UICondition.CreateFromName(packageName); var topLevelWindowCondition = CreateTopLevelWindowCondition().AndWith(nameCondition); return(UAPApp.Launch(_appName, topLevelWindowCondition)); }
private UIObject LaunchNonUWPApp(string packageName) { Debug.Assert(!_isUWPApp); var nameCondition = UICondition.CreateFromName(packageName); var topLevelWindowCondition = UICondition.CreateFromClassName("Window").AndWith(nameCondition); UIObject coreWindow = null; try { coreWindow = UAPApp.Launch(_appName, topLevelWindowCondition); } catch { // UAP.Launch launches the app, but fails trying to find a CoreWindow in the launched app. If the // App is not UWP (as in the case of WPF app hosting a XAML Island), We can fallback to looking for // just a window and use it as the root for future queries. // not a uwp app, see if we can find any window with the condition that matches. coreWindow = FindCore.ByNameAndClassName(root: UIObject.Root, name: packageName, className: "Window", shouldWait: true); } return(coreWindow); }