protected internal void RunEventScriptBlocks(HasControlInputCmdletBase cmdlet)
        {
            var blocks = new List <ScriptBlock>();

//            WriteVerbose(cmdlet,
//                              blocks.Count +
//                              " events to fire");
            if (cmdlet.EventAction != null && cmdlet.EventAction.Length > 0)
            {
                foreach (ScriptBlock sb in cmdlet.EventAction)
                {
                    blocks.Add(sb);
//                    WriteVerbose(cmdlet,
//                                      "the scriptblock: " +
//                                      sb +
//                                      " is ready to be fired");
                }
            }

            try {
                runScriptBlocks(blocks, cmdlet, true, null);
            }
            catch (Exception eScriptBlocks) {
                cmdlet.WriteError(
                    cmdlet,
                    eScriptBlocks.Message,
                    "ScriptblocksFailed",
                    ErrorCategory.InvalidResult,
                    true);
            }
            // runEventScriptBlocks(blocks, cmdlet); //, true);
        }
Beispiel #2
0
        public static IUiElement PerformCoordinatedInvokeContextMenu(this IControlInputHolder holder, int X, int Y)
        {
            var cmdlet =
                new HasControlInputCmdletBase();

            // return the context menu window
            return(holder.GetParentElement().InvokeContextMenu(cmdlet, X, Y));
        }
Beispiel #3
0
        /// <summary>
        /// Invokes the context menu and returns the object representing the menu invoked.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static IUiElement PerformInvokeContextMenu(this IControlInputHolder holder)
        {
            var cmdlet =
                new HasControlInputCmdletBase();

            // return the context menu window
            return(holder.GetParentElement().InvokeContextMenu(cmdlet, Preferences.ClickOnControlByCoordX, Preferences.ClickOnControlByCoordY));
        }
 protected internal void RunOnSleepScriptBlocks(HasControlInputCmdletBase cmdlet, object[] parameters)
 {
     if (cmdlet is HasTimeoutCmdletBase)
     {
         runTwoScriptBlockCollections(
             Preferences.OnSleepAction,
             ((HasTimeoutCmdletBase)cmdlet).OnSleepAction,
             cmdlet,
             parameters);
     }
 }
Beispiel #5
0
//        // internal static IControlInputHolder GetC(this IControlInputHolder holder)
//        internal static string GetC(this IControlInputHolder holder)
//        {
//            return "c"; // holder;
//        }

        public static IUiElement PerformClick(this IControlInputHolder holder)
        {
            var cmdlet =
                new HasControlInputCmdletBase();

            cmdlet.ClickControl(
                cmdlet,
                holder.GetParentElement(),
                new ClickSettings()
            {
                RelativeX = Preferences.ClickOnControlByCoordX,
                RelativeY = Preferences.ClickOnControlByCoordY
            });

            return(holder.GetParentElement());
        }
Beispiel #6
0
        public static IUiElement PerformCoordinatedClick(this IControlInputHolder holder, int X, int Y)
        {
            var cmdlet =
                new HasControlInputCmdletBase();

            cmdlet.ClickControl(
                cmdlet,
                holder.GetParentElement(),
                new ClickSettings()
            {
                RelativeX = X,
                RelativeY = Y
            });

            return(holder.GetParentElement());
        }
        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);
        }
 protected internal void SleepAndRunScriptBlocks(HasControlInputCmdletBase cmdlet)
 {
     RunOnSleepScriptBlocks(cmdlet, null);
     Thread.Sleep(Preferences.OnSleepDelay);
 }