public void LoadElements() { try { GuiLoggerProvider.Instance.Log("Loading Elements for UI Automation"); //var mainWindowHandle = GetHandleWindow("SimFeedback - 00.09.08"); var mainWindowHandle = _currProcess.MainWindowHandle; GuiLoggerProvider.Instance.Log("Aktuelles Window handle: " + mainWindowHandle); actionElements = new ActionElements(); if ((int)mainWindowHandle != 0) { GuiLoggerProvider.Instance.Log("Loading.."); AutomationElement root = AutomationElement.FromHandle(mainWindowHandle); GuiLoggerProvider.Instance.Log("Root Elem: " + root.Current.Name); root = AutomationElement.FromHandle(mainWindowHandle); //Instance.profilePanel = root.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "groupBox2")); Instance.profilePanel = root.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "profileView")); Instance.actionElements = new ActionElements(); GetActiveProfileEffects(); loadEffects(root); loadControllerObjects(root); loadEffectOverallSettings(root); AddProfileChangeDetector(); } GuiLoggerProvider.Instance.Log("Controller keys available: " + String.Join(", ", Instance.actionElements.Controllers.Keys)); GuiLoggerProvider.Instance.Log("Effect keys available: " + String.Join(", ", Instance.actionElements.Effects.Keys)); GuiLoggerProvider.Instance.Log("Finished Loading Elements for UI Automation"); } catch (Exception e) { GuiLoggerProvider.Instance.Log("Error during loading Elements for UI Automation. Try Reload button."); } }
public void SelectProfileTab() { var process = System.Diagnostics.Process.GetProcessesByName("SimFeedbackStart").FirstOrDefault(); if (process != null) { GuiLoggerProvider.Instance.Log("Current Process: " + process.ProcessName); GuiLoggerProvider.Instance.Log("Current Window handle: " + process.MainWindowHandle); } else { GuiLoggerProvider.Instance.Log("No process found"); } ActionElements actionElements = new ActionElements(); if (process != null && process.MainWindowHandle != null) { GuiLoggerProvider.Instance.Log("Loading.."); var root = AutomationElement.FromHandle(process.MainWindowHandle); GuiLoggerProvider.Instance.Log("root?: " + root.Current.Name); // get tab bar var tab = root.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Tab)); // get tab var item = tab.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Profiles")); if (item == null) { GuiLoggerProvider.Instance.Log("Tab item '" + "Profiles" + "' has been closed."); return; } // select it ((SelectionItemPattern)item.GetCurrentPattern(SelectionItemPattern.Pattern)).Select(); GuiLoggerProvider.Instance.Log("Tab selected"); } }