private ExpandCollapsePattern FindMenu(InkscapeMenu menu) { AutomationElement menuElement = window.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty,menu.ToString())); ExpandCollapsePattern pattern = menuElement.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; return pattern; }
/// <summary> /// HACK: Open file. /// </summary> /// <param name="fileName"></param> /*public void OpenFile(string fileName) { //@see http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx SendKeys.SendWait("^o"); Thread.Sleep(1000); AutomationElement comboBox = AutomationElement.FocusedElement; AutomationElement textBox = null; Thread.Sleep(100); if(comboBox != null) { System.Diagnostics.Debug.WriteLine("Found "+comboBox.Current.Name); comboBox.SetValue(fileName); } Thread.Sleep(1000); SendKeys.SendWait("{ENTER}"); System.Diagnostics.Debug.WriteLine("ENTER"); } */ public void OpenMenu(InkscapeMenu menu) { ExpandCollapsePattern pattern = FindMenu(menu); }