Пример #1
0
        private void TestBtn_Click(object sender, EventArgs e)
        {
            if (uiNode == null)
            {
                try
                {
                    //first select a control
                    SelectCtrlBtn_Click(null, null);
                    if (!uiNode.IsValid())
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            //get wait for ready level
            UiWaitForReadyLevels wfrLevel = UiWaitForReadyLevels.UI_WFR_INTERACTIVE;

            if (NoneBtn.Checked)
            {
                wfrLevel = UiWaitForReadyLevels.UI_WFR_NONE;
            }
            if (CompleteBtn.Checked)
            {
                wfrLevel = UiWaitForReadyLevels.UI_WFR_COMPLETE;
            }

            //get input method
            UiInputMethod inputMethod = UiInputMethod.UI_HARDWARE_EVENTS;

            if (CtrlAPIBtn.Checked)
            {
                inputMethod = UiInputMethod.UI_CONTROL_API;
            }
            if (Win32Msg.Checked)
            {
                inputMethod = UiInputMethod.UI_WIN32_MSG;
            }

            try
            {
                uiNode.waitForReadyLevel = wfrLevel;
                //write to control
                uiNode.WriteText(InputTextBox.Text, inputMethod);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void TypeBtn_Click(object sender, EventArgs e)
        {
            if (image == null)
            {
                SelectImageMessageBox();
                return;
            }

            //get input method
            UiInputMethod inputMethod = UiInputMethod.UI_HARDWARE_EVENTS;

            if (Win32MsgBtn.Checked)
            {
                inputMethod = UiInputMethod.UI_WIN32_MSG;
            }
            if (ControlAPIBtn.Checked)
            {
                inputMethod = UiInputMethod.UI_CONTROL_API;
            }

            if (!FindImage())
            {
                MessageBox.Show("The image was not found");
            }
            else
            {
                try
                {
                    //remove clipping region
                    uiNode.clippingRegion = null;
                    //get text to type
                    string inputText = InputText.Text;
                    //type to control
                    uiNode.WriteText(inputText, inputMethod);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }
        }