コード例 #1
0
        private void cboxAction_SelectedIndexChanged(object sender, EventArgs e)
        {
            //enable relevant boxes based on the action name
            SingleAction.names item = (SingleAction.names)Enum.Parse(typeof(SingleAction.names), cboxAction.Text, true);
            switch (item)
            {
            case SingleAction.names.click:
                cboxMouseButton.Enabled = true;
                cboxKeyToType.Enabled   = false;
                txtX.Enabled            = false;
                txtY.Enabled            = false;
                txtWaitTime.Enabled     = false;
                timer.Enabled           = false;
                break;

            case SingleAction.names.moveMouseToXY:
            case SingleAction.names.dragToXY:
                timer.Enabled           = true;
                txtX.Enabled            = true;
                txtY.Enabled            = true;
                cboxKeyToType.Enabled   = false;
                cboxMouseButton.Enabled = false;
                txtWaitTime.Enabled     = false;
                break;

            case SingleAction.names.KeyboardInput:
                cboxKeyToType.Enabled   = true;
                cboxMouseButton.Enabled = false;
                txtX.Enabled            = false;
                txtY.Enabled            = false;
                txtWaitTime.Enabled     = false;
                timer.Enabled           = false;
                break;

            case SingleAction.names.wait:
                txtWaitTime.Enabled     = true;
                cboxKeyToType.Enabled   = false;
                cboxMouseButton.Enabled = false;
                txtX.Enabled            = false;
                txtY.Enabled            = false;
                timer.Enabled           = false;
                break;
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //check if all enabled filds is not empty
            if (txtTextToType.Enabled && txtTextToType.Text == "")
            {
                MessageBox.Show("Required fild is empty", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtX.Enabled && txtX.Text.Trim() == "")
            {
                MessageBox.Show("Required fild is empty", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtY.Enabled && txtY.Text.Trim() == "")
            {
                MessageBox.Show("Required fild is empty", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboxKeyToType.Enabled && cboxKeyToType.Text.Trim() == "")
            {
                MessageBox.Show("Required fild is empty", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboxMouseButton.Enabled && cboxMouseButton.Text.Trim() == "")
            {
                MessageBox.Show("Required fild is empty", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //generate the new action
            //get parand
            string paramsString = "";

            if (txtX.Enabled)
            {
                int x;
                int y;
                try
                {
                    x = Convert.ToInt32(txtX.Text);
                    y = Convert.ToInt32(txtY.Text);
                }catch (Exception ex)
                {
                    MessageBox.Show("X and Y filds must be numbers", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                paramsString = x + ":" + y;
            }
            else if (txtWaitTime.Enabled)
            {
                int time;
                try
                {
                    time = Convert.ToInt32(txtWaitTime.Text);
                }catch (Exception ex)
                {
                    MessageBox.Show("Wait time fild must be numbers", "Format alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paramsString = time + "";
            }
            else if (cboxMouseButton.Enabled)
            {
                paramsString = cboxMouseButton.Text;
            }
            else if (cboxKeyToType.Enabled)
            {
                if (txtTextToType.Enabled)
                {
                    paramsString = txtTextToType.Text;
                }
                else
                {
                    paramsString = "{" + cboxKeyToType.Text + "}";
                }
            }

            SingleAction.names item   = (SingleAction.names)Enum.Parse(typeof(SingleAction.names), cboxAction.Text, true);
            SingleAction       action = new SingleAction(item, paramsString);

            //add single action to automation action
            automateAction.actions.AddLast(action);

            //refresh flow
            lvFlow.Items.Add(action.toString());

            //reload filds
            initFilds();
        }