protected void WriteObjectMethod020Highlight(PSCmdletBase cmdlet, object outputObject) { if (null == (outputObject as IUiElement)) { return; } if (string.Empty != ((HasScriptBlockCmdletBase)cmdlet).Banner) { UiaHelper.ShowBanner(((HasScriptBlockCmdletBase)cmdlet).Banner); } if (!Preferences.Highlight && !((HasScriptBlockCmdletBase)cmdlet).Highlight) { return; } IUiElement element = null; if (cmdlet == null || cmdlet is WizardCmdletBase) { return; } try { element = outputObject as IUiElement; if (null != element && // 20140312 // (int)element.Current.ProcessId > 0) { (int)element.GetCurrent().ProcessId > 0) { WriteVerbose(this, "current cmdlet: " + GetType().Name); WriteVerbose(this, "highlighting the following element:"); // 20140312 // WriteVerbose(this, "Name = " + element.Current.Name); // WriteVerbose(this, "AutomationId = " + element.Current.AutomationId); // WriteVerbose(this, "ControlType = " + element.Current.ControlType.ProgrammaticName); // WriteVerbose(this, "X = " + element.Current.BoundingRectangle.X.ToString()); // WriteVerbose(this, "Y = " + element.Current.BoundingRectangle.Y.ToString()); // WriteVerbose(this, "Width = " + element.Current.BoundingRectangle.Width.ToString()); // WriteVerbose(this, "Height = " + element.Current.BoundingRectangle.Height.ToString()); } } catch { //(Exception eee) { // nothing to do // just failed to highlight } // 20140113 // if (element == null || !(element is IUiElement) || (int) element.Current.ProcessId <= 0) return; // 20140312 // if (element == null || !(element is IUiElement) || null == element.Current || (int) element.Current.ProcessId <= 0) return; if (element == null || !(element is IUiElement) || null == element.GetCurrent() || (int)element.GetCurrent().ProcessId <= 0) { return; } WriteVerbose(this, "as it is an IUiElement, it should be highlighted"); try { WriteVerbose(this, "run Highlighter"); if (Preferences.ShowExecutionPlan) { if (Preferences.ShowInfoToolTip) { // 20131204 // ExecutionPlan.Enqueue(element, HighlighterGeneration, "name: " + element.Current.Name); // 20140312 // ExecutionPlan.Enqueue(element, "name: " + element.Current.Name); ExecutionPlan.Enqueue(element, "name: " + element.GetCurrent().Name); } else { // 20131204 // ExecutionPlan.Enqueue(element, HighlighterGeneration, string.Empty); ExecutionPlan.Enqueue(element, string.Empty); } //this.Enqueue(element); } else { // if (Preferences.ShowInfoToolTip) { UiaHelper.Highlight(element); // } else { // UiaHelper.Highlight(element); // } } WriteVerbose(this, "after running the Highlighter"); } catch (Exception ee) { WriteVerbose(this, "unable to highlight: " + ee.Message); WriteVerbose(this, outputObject.ToString()); } //} }