Description of ContextMenuSearcherData.
Inheritance: SearcherTemplateData
コード例 #1
0
        internal static IUiElement InvokeContextMenu(this IUiElement inputObject, HasControlInputCmdletBase cmdlet, int x, int y)
        {
            IUiElement resultElement = null;

            try {
                if (!cmdlet.ClickControl(
                        cmdlet,
                        inputObject,
                        new ClickSettings()
                {
                    RightClick = true,
                    RelativeX = (x < 0 ? Preferences.ClickOnControlByCoordX : x),
                    RelativeY = (y < 0 ? Preferences.ClickOnControlByCoordY : y)
                }))
                {
                }
            }
            catch (Exception) {
                throw new Exception("failed to click on the control");
            }

            // 20140116
            // what are these x and y?
            // int x = Cursor.Position.X;
            // int y = Cursor.Position.Y;

            var contextMenuSearcher =
                AutomationFactory.GetSearcherImpl <ContextMenuSearcher>();

            var contextMenuSearcherData =
                new ContextMenuSearcherData {
                InputObject = inputObject,
                ProcessId   = inputObject.GetCurrent().ProcessId
            };

            var elementsMenuRoot =
                contextMenuSearcher.GetElements(
                    contextMenuSearcherData,
                    Preferences.Timeout);

            resultElement =
                elementsMenuRoot.First(element => null != element);

            return(resultElement);
        }
コード例 #2
0
 internal static IUiElement InvokeContextMenu(this IUiElement inputObject, HasControlInputCmdletBase cmdlet, int x, int y)
 {
     IUiElement resultElement = null;
     try {
         
         if (!cmdlet.ClickControl(
                 cmdlet,
                 inputObject,
                 new ClickSettings() {
                     RightClick = true,
                     RelativeX = (x < 0 ? Preferences.ClickOnControlByCoordX : x),
                     RelativeY = (y < 0 ? Preferences.ClickOnControlByCoordY : y)
                 })) {
         }
     }
     catch (Exception) {
         throw new Exception("failed to click on the control");
     }
     
     // 20140116
     // what are these x and y?
     // int x = Cursor.Position.X;
     // int y = Cursor.Position.Y;
     
     var contextMenuSearcher =
         AutomationFactory.GetSearcherImpl<ContextMenuSearcher>();
     
     var contextMenuSearcherData =
         new ContextMenuSearcherData {
         InputObject = inputObject,
         ProcessId = inputObject.GetCurrent().ProcessId
     };
     
     var elementsMenuRoot =
         contextMenuSearcher.GetElements(
             contextMenuSearcherData,
             Preferences.Timeout);
     
     resultElement =
         elementsMenuRoot.First(element => null != element);
     
     return resultElement;
 }