当前位置: 首页>>代码示例>>C#>>正文


C# IUiElement.GetCurrent方法代码示例

本文整理汇总了C#中IUiElement.GetCurrent方法的典型用法代码示例。如果您正苦于以下问题:C# IUiElement.GetCurrent方法的具体用法?C# IUiElement.GetCurrent怎么用?C# IUiElement.GetCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUiElement的用法示例。


在下文中一共展示了IUiElement.GetCurrent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectRecursively

 public virtual List<IntPtr> CollectRecursively(
     IUiElement containerElement,
     string name,
     int level)
 {
     var resultHandle = IntPtr.Zero;
     var controlHandle = IntPtr.Zero;
     var controlHandles = new List<IntPtr>();
     var tempControlHandles = new List<IntPtr>();
     // 20140312
     // var containerHandle = new IntPtr(containerElement.Current.NativeWindowHandle);
     var containerHandle = new IntPtr(containerElement.GetCurrent().NativeWindowHandle);
     
     if (containerHandle == IntPtr.Zero) return controlHandles;
     
     // search at this level
     do {
         // using null instead of name
         controlHandle =
             NativeMethods.FindWindowEx(containerHandle, controlHandle, null, null);
         
         if (controlHandle == IntPtr.Zero) continue;
         controlHandles.Add(controlHandle);
         
         tempControlHandles =
             CollectRecursively(
                 UiElement.FromHandle(controlHandle),
                 name,
                 level + 1);
         
         if (null == tempControlHandles || 0 == tempControlHandles.Count) continue;
         controlHandles.AddRange(tempControlHandles);
         
     } while (controlHandle != IntPtr.Zero);
     
     return controlHandles;
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:37,代码来源:HandleCollector.cs

示例2: WaitIfCondition

        protected internal void WaitIfCondition(
            IUiElement _control,
            bool isEnabledOrIsVisible)
        {
            _control = InputObject.Cast<IUiElement>().ToArray()[0];
            
            // 20140312
//            if (isEnabledOrIsVisible) {
//                Wait = !(_control.Current).IsEnabled;
//            } else {
//                Wait = (_control.Current).IsOffscreen;
//            }
			Wait = isEnabledOrIsVisible ? !(_control.GetCurrent()).IsEnabled : (_control.GetCurrent()).IsOffscreen;
            do
            {
                SleepAndRunScriptBlocks(this);
                
                DateTime nowDate = DateTime.Now;
                try {
                    string tempIsReport = string.Empty;
                    // 20140312
                    // tempIsReport = isEnabledOrIsVisible ? _control.Current.IsEnabled.ToString() : _control.Current.IsOffscreen.ToString();
                    tempIsReport = isEnabledOrIsVisible ? _control.GetCurrent().IsEnabled.ToString() : _control.GetCurrent().IsOffscreen.ToString();
                    
                } catch { }
                if (!CheckAndPrepareInput(this))
                {
                    WriteObject(this, false);
                    
                    WriteError(
                        this,
                        "An unknown error while checking the control.",
                        "CheckingControl",
                        ErrorCategory.InvalidResult,
                        true);
                    
                    return;
                }
                
                // 20140312
//                if (isEnabledOrIsVisible) {
//                    Wait = !(_control.Current).IsEnabled;
//                } else {
//                    Wait = (_control.Current).IsOffscreen;
//                }
				Wait = isEnabledOrIsVisible ? !(_control.GetCurrent()).IsEnabled : (_control.GetCurrent()).IsOffscreen;
                if ((nowDate - StartDate).TotalSeconds > Timeout / 1000)
                {
                    // 20140312
//                    WriteVerbose(this, "timeout expired for AutomationId: " + 
//                                 _control.Current.AutomationId +
//                                ", title: " +
//                                 _control.Current.Name);
                    // 20140312
//                    WriteError(
//                        this,
//                        CmdletName(this) + ": timeout expired for AutomationId: " + 
//                        _control.Current.AutomationId +
//                        ", title: " +
//                        _control.Current.Name,
//                        "TimeoutExpired",
//                        ErrorCategory.OperationTimeout,
//                        true);
                    WriteError(
                        this,
                        CmdletName(this) + ": timeout expired for AutomationId: " + 
                        _control.GetCurrent().AutomationId +
                        ", title: " +
                        _control.GetCurrent().Name,
                        "TimeoutExpired",
                        ErrorCategory.OperationTimeout,
                        true);
                }
                if (_control != null) continue;
                
            } while (Wait);
        }
开发者ID:universsky,项目名称:STUPS,代码行数:77,代码来源:WaitCmdletBase.cs

示例3: SearchByExactConditionsViaUia

 internal static List<IUiElement> SearchByExactConditionsViaUia(
     IUiElement inputObject,
     Hashtable[] searchCriteria,
     classic.Condition conditions)
 {
     if (conditions == null) return new List<IUiElement>();
     
     if (inputObject == null || (int) inputObject.GetCurrent().ProcessId <= 0) return new List<IUiElement>();
     
     IUiEltCollection tempCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditions);
     
     if (null == searchCriteria || 0 == searchCriteria.Length) {
         return tempCollection.ToArray().ToList<IUiElement>();
     }
     
     return tempCollection.ToArray().Where(element => TestControlWithAllSearchCriteria(searchCriteria, element)).ToList<IUiElement>();
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:17,代码来源:ControlSearcher.cs

示例4: GetPropertyCompleteString

        private string GetPropertyCompleteString(
            IUiElement currentElement,
            string resultString,
            string propertyName)
        {
            string result = string.Empty;
            
            if ((Full) ||
                // (IsIncluded(propertyName) &&
                // (IsInArray(Include, propertyName) &&
                // !IsExcluded(propertyName))) {
                // !IsInArray(Exclude, propertyName))) {
                
                (!IsInArray(Exclude, propertyName) &&
                (0 == Include.Length || IsInArray(Include, propertyName)))) {
                
                result = propertyName;
                result += "=";
                
                // 20140312
//                switch (propertyName) {
//                    case "Name":
//                        result += PropertyToString(currentElement.Current.Name);
//                        break;
//                    case "AutomationId":
//                        result += PropertyToString(currentElement.Current.AutomationId);
//                        break;
//                    case "ControlType":
//                        result += PropertyToString(currentElement.Current.ControlType.ProgrammaticName.Substring(12));
//                        break;
//                    case "Class":
//                        result += PropertyToString(currentElement.Current.ClassName);
//                        break;
//                    case "AcceleratorKey":
//                        result += PropertyToString(currentElement.Current.AcceleratorKey);
//                        break;
//                    case "AccessKey":
//                        result += PropertyToString(currentElement.Current.AccessKey);
//                        break;
//                    case "BoundingRectangle":
//                        result += PropertyToString(currentElement.Current.BoundingRectangle.ToString());
//                        break;
//                    case "FrameworkId":
//                        result += PropertyToString(currentElement.Current.FrameworkId);
//                        break;
//                    case "HasKeyboardFocus":
//                        result += PropertyToString(currentElement.Current.HasKeyboardFocus.ToString());
//                        break;
//                    case "HelpText":
//                        result += PropertyToString(currentElement.Current.HelpText);
//                        break;
//                    case "IsContentElement":
//                        result += PropertyToString(currentElement.Current.IsContentElement.ToString());
//                        break;
//                    case "IsControlElement":
//                        result += PropertyToString(currentElement.Current.IsControlElement.ToString());
//                        break;
//                    case "IsEnabled":
//                        result += PropertyToString(currentElement.Current.IsEnabled.ToString());
//                        break;
//                    case "IsKeyboardFocusable":
//                        result += PropertyToString(currentElement.Current.IsKeyboardFocusable.ToString());
//                        break;
//                    case "IsOffscreen":
//                        result += PropertyToString(currentElement.Current.IsOffscreen.ToString());
//                        break;
//                    case "IsPassword":
//                        result += PropertyToString(currentElement.Current.IsPassword.ToString());
//                        break;
//                    case "IsRequiredForForm":
//                        result += PropertyToString(currentElement.Current.IsRequiredForForm.ToString());
//                        break;
//                    case "ItemStatus":
//                        result += PropertyToString(currentElement.Current.ItemStatus);
//                        break;
//                    case "ItemType":
//                        result += PropertyToString(currentElement.Current.ItemType);
//                        break;
//                        //case "LabeledBy":
//                        //    result +=
//                        //    break;
//                    case "LocalizedControlType":
//                        result += PropertyToString(currentElement.Current.LocalizedControlType);
//                        break;
//                    case "NativeWindowHandle":
//                        result += PropertyToString(currentElement.Current.NativeWindowHandle.ToString());
//                        break;
//                    case "Orientation":
//                        result += PropertyToString(currentElement.Current.Orientation.ToString());
//                        break;
//                    case "ProcessId":
//                        result += PropertyToString(currentElement.Current.ProcessId.ToString());
//                        break;
//                }
                switch (propertyName) {
                    case "Name":
                        result += PropertyToString(currentElement.GetCurrent().Name);
                        break;
                    case "AutomationId":
                        result += PropertyToString(currentElement.GetCurrent().AutomationId);
//.........这里部分代码省略.........
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:101,代码来源:ConvertToUiaSearchCriteriaCommand.cs

示例5: Enqueue

        public static void Enqueue(
            // 20131109
            //AutomationElement elementToHighlight,
            IUiElement elementToHighlight,
            // 20131204
            // int highlightersGeneration,
            string highlighterData)
        {
            // 20131109
            //if (null == (elementToHighlight as AutomationElement)) return;
            if (null == elementToHighlight) return;
            /*
            if (null == (elementToHighlight as IUiElement)) return;
            */
            // 20131204
//            if (0 >= highlightersGeneration) {
//                HighlighterNumber++;
//            } else {
//                HighlighterNumber = highlightersGeneration;
//            }
            if (0 == CommonCmdletBase.HighlighterGeneration) {
                CommonCmdletBase.HighlighterGeneration++;
            }
                
            // Highlighter highlighter = new Highlighter(
            var highlighter = new Highlighter(
                // 20140312
//                elementToHighlight.Current.BoundingRectangle.Height,
//                elementToHighlight.Current.BoundingRectangle.Width,
//                elementToHighlight.Current.BoundingRectangle.X,
//                elementToHighlight.Current.BoundingRectangle.Y,
//                elementToHighlight.Current.NativeWindowHandle,
                elementToHighlight.GetCurrent().BoundingRectangle.Height,
                elementToHighlight.GetCurrent().BoundingRectangle.Width,
                elementToHighlight.GetCurrent().BoundingRectangle.X,
                elementToHighlight.GetCurrent().BoundingRectangle.Y,
                elementToHighlight.GetCurrent().NativeWindowHandle,
                // 20131204
                // (Highlighters)(HighlighterNumber % 10),
                (Highlighters)(CommonCmdletBase.HighlighterGeneration % 10),
                // 20131204
                // HighlighterNumber,
                CommonCmdletBase.HighlighterGeneration,
                highlighterData);
            Enqueue(highlighter);

            /*
            if (null != (elementToHighlight as AutomationElement)) {

                if (0 >= highlightersGeneration) {
                    HighlighterNumber++;
                } else {
                    HighlighterNumber = highlightersGeneration;
                }
                
                highlighter =
                    new Highlighter(
                        elementToHighlight.Current.BoundingRectangle.Height,
                        elementToHighlight.Current.BoundingRectangle.Width,
                        elementToHighlight.Current.BoundingRectangle.X,
                        elementToHighlight.Current.BoundingRectangle.Y,
                        elementToHighlight.Current.NativeWindowHandle,
                        (Highlighters)(HighlighterNumber % 10),
                        HighlighterNumber,
                        highlighterData);
                ExecutionPlan.Enqueue(highlighter);
            }
            */
        }
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:69,代码来源:ExecutionPlan.cs

示例6: SubscribeToEvents


//.........这里部分代码省略.........
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.AutomationPropertyChangedEvent":
                 if (properties != null) {
                     classic.AutomationPropertyChangedEventHandler uiaPropertyChangedEventHandler;
                     UiaAutomation.AddAutomationPropertyChangedEventHandler(
                         inputObject,
                         classic.TreeScope.Subtree,
                         uiaPropertyChangedEventHandler = 
                             new classic.AutomationPropertyChangedEventHandler(cmdlet.AutomationPropertyChangedEventHandler),
                         properties);
                     UiaHelper.WriteEventToCollection(cmdlet, uiaPropertyChangedEventHandler);
                     if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaPropertyChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 }
                 break;
             case "AutomationElementIdentifiers.StructureChangedEvent":
                 classic.StructureChangedEventHandler uiaStructureChangedEventHandler;
                 UiaAutomation.AddStructureChangedEventHandler(
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaStructureChangedEventHandler = 
                     new classic.StructureChangedEventHandler(cmdlet.StructureChangedEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaStructureChangedEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaStructureChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "WindowPatternIdentifiers.WindowClosedProperty":
                 UiaAutomation.AddAutomationEventHandler(
                     classic.WindowPattern.WindowClosedEvent,
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaEventHandler = new classic.AutomationEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.MenuClosedEvent":
                 UiaAutomation.AddAutomationEventHandler(
                     classic.AutomationElement.MenuClosedEvent,
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaEventHandler = new classic.AutomationEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.MenuOpenedEvent":
                 UiaAutomation.AddAutomationEventHandler(
                     classic.AutomationElement.MenuOpenedEvent,
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaEventHandler = new classic.AutomationEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.ToolTipClosedEvent":
                 UiaAutomation.AddAutomationEventHandler(
                     classic.AutomationElement.ToolTipClosedEvent,
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaEventHandler = new classic.AutomationEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.ToolTipOpenedEvent":
                 UiaAutomation.AddAutomationEventHandler(
                     classic.AutomationElement.ToolTipOpenedEvent,
                     inputObject,
                     classic.TreeScope.Subtree,
                     uiaEventHandler = new classic.AutomationEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             case "AutomationElementIdentifiers.AutomationFocusChangedEvent":
                 classic.AutomationFocusChangedEventHandler uiaFocusChangedEventHandler;
                 UiaAutomation.AddAutomationFocusChangedEventHandler(
                     uiaFocusChangedEventHandler = new classic.AutomationFocusChangedEventHandler(cmdlet.AutomationEventHandler));
                 UiaHelper.WriteEventToCollection(cmdlet, uiaFocusChangedEventHandler);
                 if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaFocusChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                 break;
             default:
                 WriteVerbose(cmdlet, 
                              "the following event has not been subscribed to: " + 
                              eventType.ProgrammaticName);
                 break;
         }
         cacheRequest.Pop();
         
     } 
     catch (Exception e) {
         
         WriteVerbose(cmdlet,
                       "Unable to register event handler " +
                       eventType.ProgrammaticName +
                       " for " +
             // 20140312
                       // inputObject.Current.Name);
             inputObject.GetCurrent().Name);
          WriteVerbose(cmdlet,
                       e.Message);
     }
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:101,代码来源:HasControlInputCmdletBase.cs

示例7: ProcessAutomationElement

        private List<IUiElement> ProcessAutomationElement(
            IUiElement element,
            string name,
            string automationId,
            string className,
            string[] controlType,
            bool caseSensitive,
            bool onlyOneResult,
            bool onlyTopLevel)
        {
            var resultCollection = new List<IUiElement>();
            
			name = name ?? string.Empty;
			automationId = automationId ?? string.Empty;
			className = className ?? string.Empty;
            
            if ((controlType != null && 
                controlType.Length > 0 && 
                ElementOfPossibleControlType(
                    controlType,
                    // 20140312
                    // element.Current.ControlType.ProgrammaticName)) ||
                    element.GetCurrent().ControlType.ProgrammaticName)) ||
                (controlType == null) ||
                (controlType.Length == 0)) {

                WildcardOptions options;
                if (caseSensitive) {
                    options =
                        WildcardOptions.Compiled;
                } else {
                    options =
                        WildcardOptions.IgnoreCase |
                        WildcardOptions.Compiled;
                }
                
                if (0 == name.Length && 0 == automationId.Length && 0 == className.Length) {
                    name = "*";
                }
                
                var wildcardName = 
                    new WildcardPattern(name,options);
                
                var wildcardAutomationId = 
                    new WildcardPattern(automationId,options);
                
                var wildcardClass = 
                    new WildcardPattern(className,options);
                
                // 20130125
                // there's a bug 20130125
                bool matched = false;
                
                if (FromCache && CurrentData.CacheRequest != null) {
                    // 20140312
                    // if (name.Length > 0 && wildcardName.IsMatch(element.Cached.Name)) {
                    // if (name.Length > 0 && wildcardName.IsMatch((element as ISupportsCached).Cached.Name)) {
                    if (name.Length > 0 && wildcardName.IsMatch(element.GetCached().Name)) {
                        matched = true;
                    } else if (automationId.Length > 0 &&
                        // 20140312
					                          // wildcardAutomationId.IsMatch(element.Cached.AutomationId)) {
                        // wildcardAutomationId.IsMatch((element as ISupportsCached).Cached.AutomationId)) {
                        wildcardAutomationId.IsMatch(element.GetCached().AutomationId)) {
						matched = true;
					} else
                        // 20140312
						// matched |= className.Length > 0 && wildcardClass.IsMatch(element.Cached.ClassName);
                        // matched |= className.Length > 0 && wildcardClass.IsMatch((element as ISupportsCached).Cached.ClassName);
                        matched |= className.Length > 0 && wildcardClass.IsMatch(element.GetCached().ClassName);
                } else {
                    // 20140312
                    // if (name.Length > 0 && wildcardName.IsMatch(element.Current.Name)) {
                    if (name.Length > 0 && wildcardName.IsMatch(element.GetCurrent().Name)) {
                        matched = true;
                    } else if (automationId.Length > 0 &&
                        // 20140312
					                          // wildcardAutomationId.IsMatch(element.Current.AutomationId)) {
                        wildcardAutomationId.IsMatch(element.GetCurrent().AutomationId)) {
						matched = true;
					} else
                        // 20140312
						// matched |= className.Length > 0 && wildcardClass.IsMatch(element.Current.ClassName);
                        matched |= className.Length > 0 && wildcardClass.IsMatch(element.GetCurrent().ClassName);
                }
                
                if (matched) {
                    
                    resultCollection.Add(element);
                    
                    if (onlyOneResult) {

                        throw (new Exception("wrong code here!"));

                    } else {
                        
                        return resultCollection;
                    }
                }
                
//.........这里部分代码省略.........
开发者ID:universsky,项目名称:STUPS,代码行数:101,代码来源:GetControlCollectionCmdletBase.cs

示例8: guiWritingAutomationElementToPropertyGridControl


//.........这里部分代码省略.........
        
        // 20131109
        //private void writingAvailablePatterns(AutomationElement element)
        //        private void writingAvailablePatterns(IUiElement element)
        //        {
        //            try {
        //                this.richPatterns.Text = "available patterns";
        //                this.richPatterns.Text += "\r\n";
//
        //                // 20120618 UiaCOMWrapper
        //                // 20131209
        //                // AutomationPattern[] supportedPatterns =
        //                //     element.GetSupportedPatterns();
        //                IBasePattern[] supportedPatterns =
        //                    element.GetSupportedPatterns();
        //                //UiaCOM::System.Windows.Automation.AutomationPattern[] supportedPatterns =
        //                //    element.GetSupportedPatterns();
//
        //                if (supportedPatterns == null || supportedPatterns.Length <= 0) return;
        //                for (int i = 0; i < supportedPatterns.Length; i++) {
        //                    if (i > 0) {
        //                        this.richPatterns.Text += "\r\n";
        //                    }
        //                    this.richPatterns.Text +=
        //                        // 20131209
        //                        // supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        // 20131210
        //                        // (supportedPatterns[i] as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        // (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", string.Empty);
        //                }
//
        //                /*
        //                if (supportedPatterns != null &&
        //                    supportedPatterns.Length > 0) {
        //                    for (int i = 0; i < supportedPatterns.Length; i++) {
        //                        if (i > 0) {
        //                            this.richPatterns.Text += "\r\n";
        //                        }
        //                        this.richPatterns.Text +=
        //                            supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                    }
        //                }
        //                */
        //            }
        //            catch {}
        //        }
        
        // 20131109
        //privaIUiElementperWrapperperWrapper getElementFromPoint()
        // 20131114
        //private IUiElement getElementFromPoint()
        //        private IUiElement getElementFromPoint(System.Drawing.Point mousePoint)
        //        {
        //            // 20131109
        //            //AutomatIUiElement element = null;
        //            IUiElement element = null;
//
        //            // use Windows forms mouse code instead of WPF
        //            // 20131114
        //            //System.Drawing.Point mouse = System.Windows.Forms.Cursor.Position;
//
        //            // commented 20120618 to switch to UiaCOMWrapper
        //            element =
        //                // 20131109
        //                //System.Windows.Automation.AutomationElement.FromPoint(
        //                UiElement.FromPoint(
        //                    // 20131114
        //                    //new System.Windows.Point(mouse.X, mouse.Y));
        //                    new System.Windows.Point(mousePoint.X, mousePoint.Y));
        //            //element =
        //            //    //(UiaNET::System.Windows.Automation.AutomationElement)
        //            //    UiaCOM3.UiaCOMHelper.GetAutomationElementFromPoint();
//
        //            return element;
        //        }
        
        // 20131109
        //private void writingAutomationElementToPropertyGridControl(AutomationElement element)
        private void guiWritingAutomationElementToPropertyGridControl(IUiElement element)
        {
            try {
                pGridElement.SelectedObject =
                    // 20140312
                    // element.Current;
                    element.GetCurrent();
            }
            catch {
                try {
                    pGridElement.SelectedObject =
                        // 20140312
                        // element.Cached;
                        // (element as ISupportsCached).Cached;
                        element.GetCached();
                }
                catch {
                    
                }
            }
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:101,代码来源:SpyForm.cs

示例9: getCodeFromAutomationElement

        private string getCodeFromAutomationElement(
            // 20131109
            //IUiElement element,
            IUiElement element,
            TreeWalker walker)
        {
            string result = string.Empty;
            
            // 20140312
//            string elementControlType =
//                element.Current.ControlType.ProgrammaticName.Substring(
//                    element.Current.ControlType.ProgrammaticName.IndexOf('.') + 1);
            string elementControlType =
                element.GetCurrent().ControlType.ProgrammaticName.Substring(
                    element.GetCurrent().ControlType.ProgrammaticName.IndexOf('.') + 1);
            
            // in case this element is an upper-level Pane
            // residing directrly under the RootElement
            // change type to window
            // i.e. Get-UiaPane - >  Get-UiaWindow
            // since Get-UiaPane is unable to get something more than
            // a window's child pane control
            if (elementControlType == "Pane" || elementControlType == "Menu") {
                // 20131109
                //if (walker.GetParent(element) == AutomationElement.RootElement) {
                // 20131118
                // property to method
                //if ((new UiElement(walker.GetParent(element.SourceElement))) == UiElement.RootElement) {
                // 20140102
                // if (Equals(new UiElement(walker.GetParent(element.GetSourceElement())), UiElement.RootElement)) {
                if (Equals(new UiElement(walker.GetParent(element.GetSourceElement() as AutomationElement)), UiElement.RootElement)) {
                    elementControlType = "Window";
                }
                /*
                if ((new UiElement(walker.GetParent(element.GetSourceElement()))) == UiElement.RootElement) {
                    elementControlType = "Window";
                }
                 */
            }
            
            string elementVerbosity =
                @"Get-Uia" + elementControlType;
            // 20140312
//            try {
//                if (element.Current.AutomationId.Length > 0) {
//                    elementVerbosity += (" -AutomationId '" + element.Current.AutomationId + "'");
//                }
//            }
//            catch {
//            }
//            try {
//                if (element.Current.ClassName.Length > 0) {
//                    elementVerbosity += (" -Class '" + element.Current.ClassName + "'");
//                }
//            }
//            catch {
//            }
//            try {
//                if (element.Current.Name.Length > 0) {
//                    elementVerbosity += (" -Name '" + element.Current.Name + "'");
//                }
//            }
//            catch {
//            }
            try {
                if (element.GetCurrent().AutomationId.Length > 0) {
                    elementVerbosity += (" -AutomationId '" + element.GetCurrent().AutomationId + "'");
                }
            }
            catch {
            }
            try {
                if (element.GetCurrent().ClassName.Length > 0) {
                    elementVerbosity += (" -Class '" + element.GetCurrent().ClassName + "'");
                }
            }
            catch {
            }
            try {
                if (element.GetCurrent().Name.Length > 0) {
                    elementVerbosity += (" -Name '" + element.GetCurrent().Name + "'");
                }
            }
            catch {
            }
            
            result = elementVerbosity;
            return result;
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:89,代码来源:SpyForm.cs

示例10: getNodeNameFromAutomationElement

        // 20131109
        //private string getNodeNameFromAutomationElement(AutomationElement element)
        private string getNodeNameFromAutomationElement(IUiElement element)
        {
            string result = string.Empty;
            
            string ancName = string.Empty;
            string ancAuId = string.Empty;
            string ancClass = string.Empty;
            string ancControlType = string.Empty;
            
            // 20140312
//            try {
//                ancName = element.Current.Name;
//            } catch {}
//            try {
//                ancAuId = element.Current.AutomationId;
//            } catch {}
//            try {
//                ancClass = element.Current.ClassName;
//            } catch {}
//            try {
//                ancControlType =
//                    element.Current.ControlType.ProgrammaticName.Substring(
//                        element.Current.ControlType.ProgrammaticName.IndexOf('.') + 1);
//            } catch {}
            try {
                ancName = element.GetCurrent().Name;
            } catch {}
            try {
                ancAuId = element.GetCurrent().AutomationId;
            } catch {}
            try {
                ancClass = element.GetCurrent().ClassName;
            } catch {}
            try {
                ancControlType =
                    element.GetCurrent().ControlType.ProgrammaticName.Substring(
                        element.GetCurrent().ControlType.ProgrammaticName.IndexOf('.') + 1);
            } catch {}
            result =
                "name = '" +
                ancName +
                "'; automationId = '" +
                ancAuId +
                "'; class = '" +
                ancClass +
                "'; control type = '" +
                ancControlType +
                "'";
            
            return result;
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:53,代码来源:SpyForm.cs

示例11: GetControlTypeNameOfAutomationElement

        private string GetControlTypeNameOfAutomationElement(
            // 20131109
            //AutomationElement element,
            //AutomationElement element2)
            IUiElement element,
            IUiElement element2)
        {
            string result = String.Empty;
            // 20140312
//            if (element != null && (int)element.Current.ProcessId > 0 && 
//                element2 != null && (int)element2.Current.ProcessId > 0) {
//                element.Current.ControlType.ProgrammaticName.Substring(
//                    element2.Current.ControlType.ProgrammaticName.IndexOf('.') + 1);
            if (element != null && (int)element.GetCurrent().ProcessId > 0 && 
                element2 != null && (int)element2.GetCurrent().ProcessId > 0) {
                element.GetCurrent().ControlType.ProgrammaticName.Substring(
                    element2.GetCurrent().ControlType.ProgrammaticName.IndexOf('.') + 1);
            }
            return result;
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:20,代码来源:StartUIATranscriptCommand.cs


注:本文中的IUiElement.GetCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。