public static INode Parse(string src, TextWriter errorOut) { Element nLessRootNode = null; var bMatches = parser.Parse(); if (!bMatches) { throw new ParsingException("FAILURE: Json Parser did not match input file "); } else { Console.WriteLine("SUCCESS: Json Parser matched input file"); var root = parser.GetRoot(); try { var walker = new TreeWalker(root, src); nLessRootNode = walker.Walk(); Console.WriteLine(nLessRootNode.ToCss()); } catch (Exception ex) { Console.WriteLine(ex); } } return nLessRootNode; }
/// <summary> /// Constructs a new ExitDialog instance. /// </summary> /// <param name="Screen">A UIScreen instance.</param> /// <param name="Position">The position of this ExitDialog.</param> /// <param name="Walker">A TreeWalker instance.</param> /// <param name="ScriptPath">The path to the script which defines this ExitDialog.</param> public ExitDialog(UIScreen Screen, Vector2 Position, TreeWalker Walker, string ScriptPath) : base(Screen, Position, true, true, true) { Walker.Initialize(ScriptPath); m_Elements = Walker.Elements; m_Controls = Walker.Controls; m_ReloginButton = (UIButton)m_Elements["ReLoginButton"]; m_ExitButton = (UIButton)m_Elements["ExitButton"]; m_CancelButton = (UIButton)m_Elements["CancelButton"]; m_TitleText = (UILabel)m_Elements["TitleText"]; m_MessageText = (UILabel)m_Elements["MessageText"]; }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Expression); }
private void WalkTree(AutomationElement parent, TreeWalker walker, XmlWriter writer, IList<AutomationElement> elements) { var element = this.elementFactory.GetElement(parent); writer.WriteStartElement(element.TypeName); if (elements != null) { writer.WriteAttributeString("_index_", elements.Count.ToString()); elements.Add(parent); } writer.WriteAttributeString("id", element.ID); writer.WriteAttributeString("framework", element.UIFramework); writer.WriteAttributeString("name", element.Name); writer.WriteAttributeString("value", element.Value); writer.WriteAttributeString("class", element.ClassName); writer.WriteAttributeString("help", element.Help); writer.WriteAttributeString("visible", element.Visible ? "true" : "false"); writer.WriteAttributeString("enabled", element.Enabled ? "true" : "false"); writer.WriteAttributeString("focusable", element.Focusable ? "true" : "false"); writer.WriteAttributeString("focused", element.Focused ? "true" : "false"); writer.WriteAttributeString("selected", element.Selected ? "true" : "false"); writer.WriteAttributeString("protected", element.Protected ? "true" : "false"); writer.WriteAttributeString("scrollable", element.Scrollable ? "true" : "false"); writer.WriteAttributeString("handle", element.Handle.ToString()); writer.WriteAttributeString("x", element.X.ToString()); writer.WriteAttributeString("y", element.Y.ToString()); writer.WriteAttributeString("width", element.Width.ToString()); writer.WriteAttributeString("height", element.Height.ToString()); writer.WriteAttributeString( "bounds", string.Format("[{0},{1}][{2},{3}]", element.X, element.Y, element.Width, element.Height)); var child = walker.GetFirstChild(parent); while (child != null) { this.WalkTree(child, walker, writer, elements); child = walker.GetNextSibling(child); } writer.WriteEndElement(); }
public override void Visit(TreeWalker w) { base.Visit(w); w.WalkList(Segments); }
///-------------------------------------------------------------------- /// <summary> /// Handles user input in the target. /// </summary> /// <param name="src">Object that raised the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------- private void TargetSelectionHandler( object src, AutomationEventArgs e) { feedbackText = new StringBuilder(); // Get the name of the item, which is equivalent to its text. AutomationElement sourceItem = src as AutomationElement; SelectionItemPattern selectionItemPattern = sourceItem.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; AutomationElement sourceContainer; // Special case handling for composite controls. TreeWalker treeWalker = new TreeWalker(new PropertyCondition( AutomationElement.IsSelectionPatternAvailableProperty, true)); sourceContainer = (treeWalker.GetParent( selectionItemPattern.Current.SelectionContainer) == null) ? selectionItemPattern.Current.SelectionContainer : treeWalker.GetParent( selectionItemPattern.Current.SelectionContainer); switch (e.EventId.ProgrammaticName) { case "SelectionItemPatternIdentifiers.ElementSelectedEvent": feedbackText.Append(sourceItem.Current.Name) .Append(" of the ") .Append(sourceContainer.Current.AutomationId) .Append(" control was selected."); break; case "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent": feedbackText.Append(sourceItem.Current.Name) .Append(" of the ") .Append(sourceContainer.Current.AutomationId) .Append(" control was added to the selection."); break; case "SelectionItemPatternIdentifiers.ElementRemovedFromSelectionEvent": feedbackText.Append(sourceItem.Current.Name) .Append(" of the ") .Append(sourceContainer.Current.AutomationId) .Append(" control was removed from the selection."); break; } Feedback(feedbackText.ToString()); for (int controlCounter = 0; controlCounter < targetControls.Count; controlCounter++) { clientApp.SetControlPropertiesText(controlCounter); clientApp.EchoTargetControlSelections( targetControls[controlCounter], controlCounter); clientApp.EchoTargetControlProperties( targetControls[controlCounter], controlCounter); } }
protected override void OnContext(InAudioNode node) { var menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(node.Name)); menu.AddSeparator(""); #region Duplicate if (!node.IsRoot) { menu.AddItem(new GUIContent("Duplicate"), false, data => AudioNodeWorker.Duplicate(node), node); } else { menu.AddDisabledItem(new GUIContent("Duplicate")); } menu.AddSeparator(""); #endregion if (node.IsRootOrFolder) { menu.AddItem(new GUIContent("Create child folder in new prefab"), false, obj => { CreateFolderInNewPrefab(node); }, node); menu.AddSeparator(""); } #region Create child if (node._type == AudioNodeType.Audio || node._type == AudioNodeType.Voice) //If it is a an audio source, it cannot have any children { menu.AddDisabledItem(new GUIContent(@"Create Child/Folder")); menu.AddDisabledItem(new GUIContent(@"Create Child/Audio")); menu.AddDisabledItem(new GUIContent(@"Create Child/Random")); menu.AddDisabledItem(new GUIContent(@"Create Child/Sequence")); menu.AddDisabledItem(new GUIContent(@"Create Child/Multi")); #if UNITY_TRACK menu.AddDisabledItem(new GUIContent(@"Create Child/Track")); #endif //menu.AddDisabledItem(new GUIContent(@"Create Child/Voice")); } else { if (node.IsRootOrFolder) { menu.AddItem(new GUIContent(@"Create Child/Folder"), false, (obj) => CreateChild(node, AudioNodeType.Folder), node); } else { menu.AddDisabledItem(new GUIContent(@"Create Child/Folder")); } menu.AddItem(new GUIContent(@"Create Child/Audio"), false, (obj) => CreateChild(node, AudioNodeType.Audio), node); menu.AddItem(new GUIContent(@"Create Child/Random"), false, (obj) => CreateChild(node, AudioNodeType.Random), node); menu.AddItem(new GUIContent(@"Create Child/Sequence"), false, (obj) => CreateChild(node, AudioNodeType.Sequence), node); menu.AddItem(new GUIContent(@"Create Child/Multi"), false, (obj) => CreateChild(node, AudioNodeType.Multi), node); #if UNITY_TRACK if (node.IsRootOrFolder) { menu.AddItem(new GUIContent(@"Create Child/Track"), false, (obj) => CreateChild(node, AudioNodeType.Track), node); } else { menu.AddDisabledItem(new GUIContent(@"Create Child/Track")); } #endif //menu.AddItem(new GUIContent(@"Create Child/Track"), false, (obj) => CreateChild(node, AudioNodeType.Track), node); //menu.AddItem(new GUIContent(@"Create Child/Voice"), false, (obj) => CreateChild(node, AudioNodeType.Voice), node); } #endregion menu.AddSeparator(""); #region Add new parent if (node._parent != null && (node._parent._type == AudioNodeType.Folder || node._parent._type == AudioNodeType.Root)) { menu.AddItem(new GUIContent(@"Add Parent/Folder"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Folder), node); } else { menu.AddDisabledItem(new GUIContent(@"Add Parent/Folder")); } menu.AddDisabledItem(new GUIContent(@"Add Parent/Audio")); if (node._parent != null && node._type != AudioNodeType.Folder) { menu.AddItem(new GUIContent(@"Add Parent/Random"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Random), node); menu.AddItem(new GUIContent(@"Add Parent/Sequence"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Sequence), node); menu.AddItem(new GUIContent(@"Add Parent/Multi"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Multi), node); //menu.AddItem(new GUIContent(@"Add Parent/Track"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Track), node); } else { menu.AddDisabledItem(new GUIContent(@"Add Parent/Random")); menu.AddDisabledItem(new GUIContent(@"Add Parent/Sequence")); menu.AddDisabledItem(new GUIContent(@"Add Parent/Multi")); //menu.AddDisabledItem(new GUIContent(@"Add Parent/Track")); } //menu.AddDisabledItem(new GUIContent(@"Add Parent/Voice")); #endregion menu.AddSeparator(""); #region Convert to if (node._children.Count == 0 && !node.IsRootOrFolder) { menu.AddItem(new GUIContent(@"Convert To/Audio"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Audio), node); } else { menu.AddDisabledItem(new GUIContent(@"Convert To/Audio")); } if (!node.IsRootOrFolder) { menu.AddItem(new GUIContent(@"Convert To/Random"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Random), node); menu.AddItem(new GUIContent(@"Convert To/Sequence"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Sequence), node); menu.AddItem(new GUIContent(@"Convert To/Multi"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Multi), node); //menu.AddItem(new GUIContent(@"Convert To/Track"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Track), node); } else { menu.AddDisabledItem(new GUIContent(@"Convert To/Random")); menu.AddDisabledItem(new GUIContent(@"Convert To/Sequence")); menu.AddDisabledItem(new GUIContent(@"Convert To/Multi")); //menu.AddDisabledItem(new GUIContent(@"Add Parent/Track")); } #endregion menu.AddSeparator(""); #region Send to event if (!node.IsRootOrFolder) { menu.AddItem(new GUIContent("Send to Event Window"), false, () => EditorWindow.GetWindow <EventWindow>().ReceiveNode(node)); } else { menu.AddDisabledItem(new GUIContent("Send to Event Window")); } #endregion menu.AddSeparator(""); #region Delete if (node._type != AudioNodeType.Root) { menu.AddItem(new GUIContent("Delete"), false, obj => { treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode); AudioNodeWorker.DeleteNode(node); }, node); } else { menu.AddDisabledItem(new GUIContent("Delete")); } #endregion menu.ShowAsContext(); }
public override void Visit(TreeWalker w) { base.Visit(w); w.WalkList(Body); }
private static void TestByAutomationElementAPI() { 等待(1); var window = new TreeWalker( new AndCondition ( new PropertyCondition(AutomationElement.NameProperty, "指标管理系统"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window) ) ).GetFirstChild(AutomationElement.RootElement); var page = window.FindFirst(TreeScope.Subtree, new AndCondition ( new PropertyCondition(AutomationElement.NameProperty, "专业字典"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem) )); var button = page.FindFirst(TreeScope.Subtree, new AndCondition ( new PropertyCondition(AutomationElement.NameProperty, "添加"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button) )); var p1 = button.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; p1.Invoke(); var treeGrid = page.FindFirst(TreeScope.Subtree, new AndCondition ( new PropertyCondition(AutomationElement.NameProperty, "专业字典"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Tree) )); var siPattern = treeGrid.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern; var rowElement = siPattern.Current.GetSelection()[0]; var cellElement = rowElement.FindFirst(TreeScope.Subtree, new AndCondition ( new PropertyCondition(AutomationElement.NameProperty, "专业名称"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom) )); var value = cellElement.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty); value = cellElement.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty); var p2 = cellElement.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; p2.Invoke(); //var wpfCell = Microsoft.VisualStudio.TestTools.UITesting.UITestControlFactory.FromNativeElement(cell, "UIA") as WpfControl; //wpfCell.点击(); var editingCellElement = rowElement.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.NameProperty, "专业名称")); var vp = editingCellElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; vp.SetValue("DDDDDDDDDDDDDDDDDDDDD"); //var edit = Microsoft.VisualStudio.TestTools.UITesting.UITestControlFactory.FromNativeElement(editingCellElement, "UIA") as WpfEdit; //edit.Text = "ddddddddddd"; //var patterns = editingCell.GetSupportedPatterns(); return; }
public override void Visit(TreeWalker w) { w.Walk(Init); w.Walk(Object); base.Visit(w); }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Bcatch); w.Walk(Bfinally); }
public static List <InAudioBankLink> GetAllBanks() { return(TreeWalker.FindAll(InAudioInstanceFinder.DataManager.BankLinkTree, node => node)); }
/// <summary> /// Download IE file. /// </summary> /// <param name="action">Action can be Save/Save As/Open/Cancel.</param> /// <param name="path">Path where file needs to be saved (for Save As function).</param> public static void DownloadIEFile(string action, string path = "", string regexPatternToMatch = "") { Browser browser = null; if (Utility.Browser != null) // Utility.Browser is my WatiN browser instance. { if (string.IsNullOrEmpty(regexPatternToMatch)) { browser = Utility.Browser; } else { Utility.Wait(() => (browser = Browser.AttachTo<IE>(Find.ByUrl(new System.Text.RegularExpressions.Regex(regexPatternToMatch)))) != null); Navigation.WaitUntilReportIsCompletelyLoaded(browser); } } else { Utility.Log("Browser object does not exists."); return; } // If doesn't work try to increase sleep interval or write your own waitUntill method Thread.Sleep(3000); // See information here (http://msdn.microsoft.com/en-us/library/windows/desktop/ms633515(v=vs.85).aspx) Window windowMain = null; Utility.Wait(() => (windowMain = new Window(NativeMethods.GetWindow(browser.hWnd, 5))).ProcessID != 0); TreeWalker trw = new TreeWalker(Condition.TrueCondition); AutomationElement mainWindow = trw.GetParent(AutomationElement.FromHandle(browser.hWnd)); Window windowDialog = null; Utility.Wait(() => (windowDialog = new Window(NativeMethods.GetWindow(windowMain.Hwnd, 5))).ProcessID != 0); windowDialog.SetActivate(); AutomationElementCollection amc = null; Utility.Wait(() => (amc = AutomationElement.FromHandle(windowDialog.Hwnd).FindAll(TreeScope.Children, Condition.TrueCondition)).Count > 1); foreach (AutomationElement element in amc) { // You can use "Save ", "Open", ''Cancel', or "Close" to find necessary button Or write your own enum if (element.Current.Name.Equals(action)) { // If doesn't work try to increase sleep interval or write your own waitUntil method // WaitUntilButtonExsist(element,100); Thread.Sleep(1000); AutomationPattern[] pats = element.GetSupportedPatterns(); // Replace this for each if you need 'Save as' with code bellow foreach (AutomationPattern pat in pats) { // '10000' button click event id if (pat.Id == 10000) { InvokePattern click = (InvokePattern)element.GetCurrentPattern(pat); click.Invoke(); } } } else if (element.Current.Name.Equals("Save") && action == "Save As") { AutomationElementCollection bmc = element.FindAll(TreeScope.Children, Automation.ControlViewCondition); InvokePattern click1 = (InvokePattern)bmc[0].GetCurrentPattern(AutomationPattern.LookupById(10000)); click1.Invoke(); Thread.Sleep(1000); AutomationElementCollection main = mainWindow.FindAll(TreeScope.Children, Condition.TrueCondition); foreach (AutomationElement el in main) { if (el.Current.LocalizedControlType == "menu") { // First array element 'Save', second array element 'Save as', third second array element 'Save and open' InvokePattern clickMenu = (InvokePattern) el.FindAll(TreeScope.Children, Condition.TrueCondition)[1].GetCurrentPattern(AutomationPattern.LookupById(10000)); clickMenu.Invoke(); Thread.Sleep(1000); ControlSaveDialog(mainWindow, path); break; } } } } }
private void DrawMissingDataCreation() { bool missingaudio = Manager.AudioTree == null; bool missingaudioEvent = Manager.EventTree == null; bool missingbus = Manager.BusTree == null; bool missingbankLink = Manager.BankLinkTree == null; bool areAnyMissing = missingaudio | missingaudioEvent | missingbus | missingbankLink; if (areAnyMissing) { string missingAudioInfo = missingaudio ? "Audio Data\n" : ""; string missingEventInfo = missingaudioEvent ? "Event Data\n" : ""; string missingBusInfo = missingbus ? "Bus Data\n" : ""; string missingBankInfo = missingbankLink ? "BankLink Data\n" : ""; EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox(missingAudioInfo + missingEventInfo + missingBusInfo + missingBankInfo + "is missing.", MessageType.Error, true); bool areAllMissing = missingaudio && missingaudioEvent && missingbus && missingbankLink; if (!areAllMissing) { if (GUILayout.Button("Create missing content", GUILayout.Height(30))) { int levelSize = 3; //How many subfolders by default will be created. Number is only a hint for new people if (missingbus) { CreateBusPrefab(); } if (missingaudio) { CreateAudioPrefab(levelSize, Manager.BusTree); } if (missingaudioEvent) { CreateEventPrefab(levelSize); } if (missingbankLink) { CreateBankLinkPrefab(); } Manager.Load(true); if (missingaudio) { NodeWorker.AssignToNodes(Manager.AudioTree, node => node.Bus = Manager.BusTree); } if (missingbus && Manager.AudioTree != null && Manager.BusTree != null) { TreeWalker.ForEach(Manager.AudioTree, node => { if (node != null && node.Bus == null) { node.Bus = Manager.BusTree; } }); } if (Manager.AudioTree != null && Manager.BankLinkTree != null) { NodeWorker.AssignToNodes(Manager.AudioTree, node => { var data = (node.NodeData as InFolderData); if (data != null) { data.BankLink = Manager.BankLinkTree.GetChildren[0]; } }); } EditorApplication.SaveCurrentSceneIfUserWantsTo(); } } DrawStartFromScratch(); EditorGUILayout.EndVertical(); } }
public AutomationElementXPathNavigator(UiElement rootElement) { this.treeWalker = TreeWalker.ControlViewWalker; this.rootElement = rootElement; this.currentElement = rootElement.AutomationElement; }
public override void Visit(TreeWalker w) { base.Visit(w); w.WalkList(Definitions); }
public override void Visit(TreeWalker w) { w.Walk(Condition); base.Visit(w); w.Walk(Alternative); }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Label); }
public override void Visit(TreeWalker w) { w.Walk(Name); w.WalkList(ArgNames); base.Visit(w); }
private static void Worker() { TreeWalker walker = TreeWalker.RawViewWalker; string thisFileName = string.Empty; while (Global.isRunning) { Thread.Sleep(130); // Obtain the handle of the active window. IntPtr win_id = GetForegroundWindow(); if (win_id == IntPtr.Zero) { passFileName = string.Empty; watchFileName = string.Empty; continue; } if (watchFileName != thisFileName) { watchFileName = thisFileName; stopwatch.Restart(); } if (stopwatch.ElapsedMilliseconds >= 500) { passFileName = watchFileName; } try { // string win_title = WinGetText(win_id); var aWin = AutomationElement.FromHandle(win_id); var aCtrl = AutomationElement.FocusedElement; // todo, parent closed exception thisFileName = string.Empty; // Notepad++ // Window Class = "Notepad++" // Window Title contains filename, start with (optional) "*", and end with "Notepad++" if (aWin.Current.ClassName.ToLower() == "Notepad++".ToLower()) { Match m = Regex.Match(aWin.Current.Name, @"([^*]+\.md) - Notepad\+\+"); if (m.Success) { thisFileName = m.Groups[1].Value.Replace("*", ""); } continue; } // PSPad // Window Class = "TfPSPad.UnicodeClass", or contains "TfPSPad" // Window Title start with "PSPad -", contains [filename *] if (aWin.Current.ClassName.ToLower().Contains("TfPSPad".ToLower())) { Match m = Regex.Match(aWin.Current.Name, @"PSPad[^[]+\[(.+\.md)( \*)*\]"); // todo, more robust if (m.Success) { thisFileName = m.Groups[1].Value.Replace(" *", ""); // todo, more robust } continue; } // VisualStudio // AutomationId = "VisualStudioMainWindow" // Active Control has higher node that AutomationId contains |filename| if (aWin.Current.AutomationId.ToLower() == "VisualStudioMainWindow".ToLower()) { var aUp = Up(aCtrl, x => Regex.Match(x.Current.AutomationId, @"\|([^*|]+\.md)\|").Success); if (aUp == null) { continue; } Match m = Regex.Match(aUp.Current.AutomationId, @"\|([^*|]+\.md)\|"); if (m.Success) { thisFileName = m.Groups[1].Value.Replace("*", ""); } continue; } // File Explorer // Window Class = "CabinetWClass" // Active Control Class = "UIItem", and ControlType.ListItem // => SelectionItemPattern => Name => File Name // => Toolbar ( .ReBarWindow32 .[Breadcrumb Parent] .ToolbarWindow32 ) => Name => Path if (aWin.Current.ClassName.Equals("CabinetWClass", StringComparison.InvariantCultureIgnoreCase)) // win10, QTTabBar { if (aCtrl.Current.ClassName.Equals("UIItem", StringComparison.InvariantCultureIgnoreCase) && aCtrl.Current.ControlType == ControlType.ListItem) { var selectItem = (aCtrl.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern).Current; string name = aCtrl.Current.Name; if (!name.EndsWith(".md", StringComparison.InvariantCultureIgnoreCase) || !selectItem.IsSelected) { continue; } var aToolbar = Dn(aWin, new List <Condition>() { new Condition(x => x.Current.ClassName, "ReBarWindow32"), new Condition(x => x.Current.ClassName, "Breadcrumb Parent"), new Condition(x => x.Current.ClassName, "ToolbarWindow32") }); Match m = Regex.Match(aToolbar.Current.Name, @": (.+)"); if (!m.Success) { continue; } string path = m.Groups[1].Value; thisFileName = Path.Combine(path, name); continue; } } } catch (Exception ee) { Global.myDebug(ee.Message, 0); } } passFileName = string.Empty; }
public override void Visit(TreeWalker w) { w.Walk(ModuleName); base.Visit(w); }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Left); w.Walk(Right); }
private InfoItem GetActiveItemFromHandle(string processName, IntPtr handle) { try { if (processName == ProcessList.iexplore.ToString()) { #region IE IEAccessible tabs = new IEAccessible(); string pageTitle = tabs.GetActiveTabCaption(handle); string pageURL = tabs.GetActiveTabUrl(handle); return(new InfoItem { Title = pageTitle, Uri = pageURL, Type = InfoItemType.Web, }); #endregion } else if (processName == ProcessList.firefox.ToString()) { #region FireFox AutomationElement ff = AutomationElement.FromHandle(handle); System.Windows.Automation.Condition condition1 = new PropertyCondition(AutomationElement.IsContentElementProperty, true); System.Windows.Automation.Condition condition2 = new PropertyCondition(AutomationElement.ClassNameProperty, "MozillaContentWindowClass"); TreeWalker walker = new TreeWalker(new AndCondition(condition1, condition2)); AutomationElement elementNode = walker.GetFirstChild(ff); ValuePattern valuePattern; if (elementNode != null) { AutomationPattern[] pattern = elementNode.GetSupportedPatterns(); foreach (AutomationPattern autop in pattern) { if (autop.ProgrammaticName.Equals("ValuePatternIdentifiers.Pattern")) { valuePattern = elementNode.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; string pageURL = valuePattern.Current.Value.ToString(); string pageTitle = GetActiveWindowText(handle); pageTitle = pageTitle.Remove(pageTitle.IndexOf(" - Mozilla Firefox")); return(new InfoItem { Title = pageTitle, Uri = pageURL, Type = InfoItemType.Web, }); } } } return(null); #endregion } else if (processName == "chrome") { String pageURL = string.Empty; String pageTitle = string.Empty; IntPtr urlHandle = FindWindowEx(handle, IntPtr.Zero, "Chrome_AutocompleteEditView", null); //IntPtr titleHandle = FindWindowEx(handle, IntPtr.Zero, "Chrome_WindowImpl_0", null); IntPtr titleHandle = FindWindowEx(handle, IntPtr.Zero, "Chrome_WidgetWin_0", null); const int nChars = 256; StringBuilder Buff = new StringBuilder(nChars); int length = SendMessage(urlHandle, WM_GETTEXTLENGTH, 0, 0); if (length > 0) { //Get URL from chrome tab SendMessage(urlHandle, WM_GETTEXT, nChars, Buff); pageURL = Buff.ToString(); //Get the title GetWindowText((int)titleHandle, Buff, nChars); pageTitle = Buff.ToString(); return(new InfoItem { Title = pageTitle, Uri = pageURL, Type = InfoItemType.Web, }); } else { return(null); } } else if (processName == ProcessList.OUTLOOK.ToString()) { #region Outlook MS_Outlook.Application outlookApp; MS_Outlook.MAPIFolder currFolder; MS_Outlook.Inspector inspector; MS_Outlook.MailItem mailItem; outlookApp = (MS_Outlook.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application"); currFolder = outlookApp.ActiveExplorer().CurrentFolder; inspector = outlookApp.ActiveInspector(); if (inspector == null) { mailItem = (MS_Outlook.MailItem)outlookApp.ActiveExplorer().Selection[1]; } else { Regex regex = new Regex(@"\w* - Microsoft Outlook"); if (regex.IsMatch(GetActiveWindowText(handle))) { mailItem = (MS_Outlook.MailItem)outlookApp.ActiveExplorer().Selection[1]; } else { mailItem = (MS_Outlook.MailItem)inspector.CurrentItem; } } string subject = mailItem.Subject; string entryID = mailItem.EntryID; return(new InfoItem { Title = subject, Uri = entryID, Type = InfoItemType.Email, }); #endregion } else if (processName == ProcessList.WINWORD.ToString() || processName == ProcessList.EXCEL.ToString() || processName == ProcessList.POWERPNT.ToString() || processName == ProcessList.AcroRd32.ToString()) { #region Word, Excel, PPT, Adobe Reader return(null); #endregion } else { return(null); } } catch (Exception) { return(null); } }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Name); w.Walk(ForeignName); }
public static IEnumerable <EnumObject> DeserializeObjects(string sourceFile) { TreeWalker walker = new TreeWalker(); return(walker.GetEnumObjects(sourceFile)); }
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Prefix); w.Walk(TemplateString); }
private static string GetXPathToElement(AutomationElement element, TreeWalker treeWalker, UiElement?rootElement = null) { var parent = treeWalker.GetParent(element); if (parent is null || (rootElement is { } &&
public override void Visit(TreeWalker w) { base.Visit(w); w.Walk(Key); w.Walk(Value); }
private void InterpretText() { var parser = new Altaxo_LabelV1(); parser.SetSource(_text); bool bMatches = parser.MainSentence(); var tree = parser.GetRoot(); TreeWalker walker = new TreeWalker(_text); StyleContext style = new StyleContext(_font, _textBrush); style.BaseFontId = _font; _rootNode = walker.VisitTree(tree, style, _lineSpacingFactor, true); }
public override void Visit(TreeWalker w) { base.Visit(w); w.WalkList(Properties); }
private void collectAncestry( ref System.Collections.Generic.List <string> listForNodes, ref System.Collections.Generic.List <string> listForCode, IUiElement element) { cleanAncestry(); TreeWalker walker = new TreeWalker( Condition.TrueCondition); try { // 20131109 //AutomationElementIUiElement testparent = element; IUiElement testparent = element; // 20140312 // if (testparent != null && (int)testparent.Current.ProcessId > 0) { if (testparent != null && (int)testparent.GetCurrent().ProcessId > 0) { listForNodes.Add(getNodeNameFromAutomationElement(testparent)); // 20131109 //if (testparent != AutomationElement.RootElement) { if (!Equals(testparent, UiElement.RootElement)) { listForCode.Add(getCodeFromAutomationElement(testparent, walker)); } /* * if (testparent != UiElement.RootElement) { * listForCode.Add(getCodeFromAutomationElement(testparent, walker)); * } */ } // 20140312 // while (testparent != null && (int)testparent.Current.ProcessId > 0) { while (testparent != null && (int)testparent.GetCurrent().ProcessId > 0) { testparent = // 20131109 //walker.GetParent(testparent); // 20131118 // property to method //new UiElement(walker.GetParent(testparent.SourceElement)); // 20140102 // new UiElement(walker.GetParent(testparent.GetSourceElement())); new UiElement(walker.GetParent(testparent.GetSourceElement() as AutomationElement)); // 20140312 // if (testparent.Current.ProcessId <= 0) continue; if (testparent.GetCurrent().ProcessId <= 0) { continue; } /* * if (testparent == null || (int) testparent.Current.ProcessId <= 0) continue; */ listForNodes.Add(getNodeNameFromAutomationElement(testparent)); // 20131109 //if (testparent != AutomationElement.RootElement) { if (!Equals(testparent, UiElement.RootElement)) { listForCode.Add(getCodeFromAutomationElement(testparent, walker)); } /* * if (testparent != UiElement.RootElement) { * listForCode.Add(getCodeFromAutomationElement(testparent, walker)); * } */ /* * if (testparent != null && (int)testparent.Current.ProcessId > 0) { * listForNodes.Add(getNodeNameFromAutomationElement(testparent)); * if (testparent != AutomationElement.RootElement) { * listForCode.Add(getCodeFromAutomationElement(testparent, walker)); * } * } */ } } catch (Exception eNew) { txtFullCode.Text = eNew.Message; } }
public override void Visit(TreeWalker w) { w.Walk(Argname); base.Visit(w); }
protected override void OnContext(InAudioEventNode node) { var menu = new GenericMenu(); #region Duplicate if (!node.IsRoot) { menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as InAudioEventNode), node); } else { menu.AddDisabledItem(new GUIContent("Duplicate")); } menu.AddSeparator(""); #endregion #region Duplicate if (node.IsRootOrFolder) { menu.AddItem(new GUIContent("Create child folder in new prefab"), false, obj => { CreateFolderInNewPrefab(node); }, node); menu.AddSeparator(""); } #endregion #region Create child if (node._type == EventNodeType.Root || node._type == EventNodeType.Folder) { menu.AddItem(new GUIContent(@"Create Event"), false, data => { CreateChild(node, EventNodeType.Event); }, node); menu.AddItem(new GUIContent(@"Create Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node); } if (node._type == EventNodeType.Event) { menu.AddDisabledItem(new GUIContent(@"Create Event")); menu.AddDisabledItem(new GUIContent(@"Create Folder")); } #endregion menu.AddSeparator(""); #region Delete menu.AddItem(new GUIContent(@"Delete"), false, data => { treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode); AudioEventWorker.DeleteNode(node); }, node); #endregion menu.ShowAsContext(); }
private void WalkTree(AutomationElement parent, TreeWalker walker, XmlWriter writer, IList<AutomationElement> elements) { var element = this.elementFactory.GetElement(parent); writer.WriteStartElement(element.TypeName); if (elements != null) { writer.WriteAttributeString("_index_", elements.Count.ToString()); elements.Add(parent); } writer.WriteAttributeString("id", element.ID); writer.WriteAttributeString("framework", element.UIFramework); writer.WriteAttributeString("name", element.Name); writer.WriteAttributeString("value", element.Value); writer.WriteAttributeString("class", element.ClassName); writer.WriteAttributeString("help", element.Help); writer.WriteAttributeString("visible", element.Visible ? "true" : "false"); writer.WriteAttributeString("enabled", element.Enabled ? "true" : "false"); writer.WriteAttributeString("focusable", element.Focusable ? "true" : "false"); writer.WriteAttributeString("focused", element.Focused ? "true" : "false"); writer.WriteAttributeString("selected", element.Selected ? "true" : "false"); writer.WriteAttributeString("protected", element.Protected ? "true" : "false"); writer.WriteAttributeString("scrollable", element.Scrollable ? "true" : "false"); writer.WriteAttributeString("handle", element.Handle.ToString()); writer.WriteAttributeString("x", element.X.ToString()); writer.WriteAttributeString("y", element.Y.ToString()); writer.WriteAttributeString("width", element.Width.ToString()); writer.WriteAttributeString("height", element.Height.ToString()); writer.WriteAttributeString( "bounds", string.Format("[{0},{1}][{2},{3}]", element.X, element.Y, element.Width, element.Height)); var node = walker.GetFirstChild(parent); var children = new List<AutomationElement>(); while (node != null) { this.WalkTree(node, walker, writer, elements); children.Add(node); node = walker.GetNextSibling(node); // GetNextSibling may recursively return the first child again. if (node != null && children.Contains(node)) { logger.Warn("Next sibling node causes a loop. STOP!"); node = null; break; } } writer.WriteEndElement(); }
internal Enumerator(AvlTree <T> tree) { _tree = tree; _version = _tree._version; _walker = new TreeWalker(tree); }