Esempio n. 1
0
        private void BuildWaitForElementActionCommand()
        {
            var waitElementActionCommand = new UIAutomationCommand
            {
                v_WindowName          = _windowName,
                v_UIASearchParameters = SearchParameters,
                v_AutomationType      = "Wait For Element To Exist"
            };

            DataTable webActionDT = waitElementActionCommand.v_UIAActionParameters;
            DataRow   timeoutRow  = webActionDT.NewRow();

            timeoutRow["Parameter Name"]  = "Timeout (Seconds)";
            timeoutRow["Parameter Value"] = "30";
            webActionDT.Rows.Add(timeoutRow);

            _sequenceCommandList.Add(waitElementActionCommand);
        }
Esempio n. 2
0
        private void ShowElementRecorder(object sender, EventArgs e, IfrmCommandEditor editor)
        {
            //get command reference
            UIAutomationCommand cmd = (UIAutomationCommand)((frmCommandEditor)editor).SelectedCommand;

            //create recorder
            frmAdvancedUIElementRecorder newElementRecorder = new frmAdvancedUIElementRecorder();

            newElementRecorder.SearchParameters = cmd.v_UIASearchParameters;

            //show form
            newElementRecorder.ShowDialog();

            ComboBox txtWindowName = (ComboBox)((frmCommandEditor)editor).flw_InputVariables.Controls["v_WindowName"];

            txtWindowName.Text = newElementRecorder.cboWindowTitle.Text;

            ((frmCommandEditor)editor).WindowState = FormWindowState.Normal;
            ((frmCommandEditor)editor).BringToFront();
        }
Esempio n. 3
0
        private void BuildElementClickActionCommand(string clickType)
        {
            BuildWaitForElementActionCommand();

            var clickElementActionCommand = new UIAutomationCommand
            {
                v_WindowName          = _windowName,
                v_UIASearchParameters = SearchParameters,
                v_AutomationType      = "Click Element"
            };

            DataTable webActionDT  = clickElementActionCommand.v_UIAActionParameters;
            DataRow   clickTypeRow = webActionDT.NewRow();

            clickTypeRow["Parameter Name"]  = "Click Type";
            clickTypeRow["Parameter Value"] = clickType;
            webActionDT.Rows.Add(clickTypeRow);

            _sequenceCommandList.Add(clickElementActionCommand);

            _stopwatch.Restart();
        }
Esempio n. 4
0
        private void BuildElementSetTextActionCommand(Keys key)
        {
            bool toUpperCase = false;

            //determine if casing is needed
            if (GlobalHook.IsKeyDown(Keys.ShiftKey) && GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = false;
            }
            else if (!GlobalHook.IsKeyDown(Keys.ShiftKey) && GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = true;
            }
            else if (GlobalHook.IsKeyDown(Keys.ShiftKey) && !GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = true;
            }
            else if (!GlobalHook.IsKeyDown(Keys.ShiftKey) && !GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = false;
            }

            var buf           = new StringBuilder(256);
            var keyboardState = new byte[256];

            if (toUpperCase)
            {
                keyboardState[(int)Keys.ShiftKey] = 0xff;
            }

            GlobalHook.ToUnicode((uint)key, 0, keyboardState, buf, 256, 0);
            var selectedKey = buf.ToString();

            //translate key press to sendkeys identifier
            if (key.ToString() == GlobalHook.StopHookKey)
            {
                //STOP HOOK
                GlobalHook.StopHook();
                GlobalHook.HookStopped  -= GlobalHook_HookStopped;
                GlobalHook.MouseEvent   -= GlobalHook_MouseEvent;
                GlobalHook.KeyDownEvent -= GlobalHook_KeyDownEvent;
                return;
            }
            else
            {
                bool result = GlobalHook.BuildSendAdvancedKeystrokesCommand(key, _sequenceCommandList, _windowName);
                if (result)
                {
                    return;
                }
            }

            //generate sendkeys together
            if ((_sequenceCommandList.Count > 1) && (_sequenceCommandList[_sequenceCommandList.Count - 1] is UIAutomationCommand) &&
                (_sequenceCommandList[_sequenceCommandList.Count - 1] as UIAutomationCommand).v_AutomationType == "Set Text")
            {
                var lastCreatedSendKeysCommand = (UIAutomationCommand)_sequenceCommandList[_sequenceCommandList.Count - 1];

                //append chars to previously created command
                //this makes editing easier for the user because only 1 command is issued rather than multiples
                var previouslyInputChars = lastCreatedSendKeysCommand.v_UIAActionParameters.Rows[0][1].ToString();
                lastCreatedSendKeysCommand.v_UIAActionParameters.Rows[0][1] = previouslyInputChars + selectedKey;
            }
            else
            {
                BuildWaitForElementActionCommand();

                //build keyboard command
                var setTextElementActionCommand = new UIAutomationCommand
                {
                    v_WindowName          = _windowName,
                    v_UIASearchParameters = SearchParameters,
                    v_AutomationType      = "Set Text"
                };

                DataTable webActionDT  = setTextElementActionCommand.v_UIAActionParameters;
                DataRow   textToSetRow = webActionDT.NewRow();
                textToSetRow["Parameter Name"]  = "Text To Set";
                textToSetRow["Parameter Value"] = selectedKey;
                webActionDT.Rows.Add(textToSetRow);

                _sequenceCommandList.Add(setTextElementActionCommand);
            }
        }