コード例 #1
0
        private void btnRectangle_Click(object sender, EventArgs e)
        {
            UIElem uiElem = null;

            try
            {
                uiElem = ComFactory.Instance.NewUIElem();
                uiElem.UseClientCoordinates = false;
                uiElem.InitializeFromID(txtID.Text, false);

                // click on the element
                int flags = (int)UIE_ClickFlags.UIE_CF_MOVE_CURSOR | (int)UIE_ClickFlags.UIE_CF_SINGLE | (int)UIE_ClickFlags.UIE_CF_LEFT;
                uiElem.Activate();
                uiElem.Click(2, 2, flags);

                // write text
                int method = 0;
                if (radioAPI.Checked == true)
                {
                    method = (int)UIE_WriteTextMethod.UIE_WTM_NATIVE;
                }
                else if (radioSendKeys.Checked == true)
                {
                    method = (int)UIE_WriteTextMethod.UIE_WTM_SENDKEYS;
                }
                string strErase = "[k(end)d(shift)k(home)u(shift)k(del)]";
                uiElem.WriteText(method, strErase + txtWriteText.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void SearchText(bool bClickText)
        {
            // get the hwnd
            int hwnd;

            hwnd = int.Parse(txtHandle.Text, System.Globalization.NumberStyles.HexNumber);

            // get the rectangle
            int x = int.Parse(txtX.Text);
            int y = int.Parse(txtY.Text);
            int w = int.Parse(txtWidth.Text);
            int h = int.Parse(txtHeight.Text);

            int occurence = int.Parse(txtOccurence.Text);

            try
            {
                // create the rectangle of the of the
                // clicked region
                rect rectangle = ComFactory.Instance.NewRect();
                rectangle.RLeft   = x;
                rectangle.RRight  = x + w;
                rectangle.RTop    = y;
                rectangle.RBottom = y + h;

                m_tCapture.UseClientCoordinates = true;

                // get the rectangle of the searched text
                rect foundRect = null;
                if (radioNative.Checked == true)
                {
                    foundRect = m_tCapture.GetRectFromText(hwnd, txtSearch.Text, rectangle, occurence);
                }
                else if (radioOCR.Checked == true)
                {
                    string strLang = (string)comboLang.Items[comboLang.SelectedIndex];
                    foundRect = m_tOCRCapture.GetRectFromText(hwnd, txtSearch.Text, rectangle, strLang, false, occurence);
                }

                // show the coordinates
                txtFoundX.Text = foundRect.RLeft.ToString();
                txtFoundY.Text = foundRect.RTop.ToString();
                txtFoundW.Text = foundRect.width().ToString();
                txtFoundH.Text = foundRect.height().ToString();

                if (bClickText)
                {
                    UIElem uiElem = ComFactory.Instance.NewUIElem();
                    uiElem.InitializeFromID(txtID.Text, false);

                    uiElem.Click(foundRect.RLeft + 2, foundRect.RTop + 2, GetClickFlags());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            UIElem uiElem = null;

            try
            {
                uiElem = ComFactory.Instance.NewUIElem();
                uiElem.UseClientCoordinates = true;
                uiElem.InitializeFromID(txtID.Text, true);

                int left, top, right, bottom;
                uiElem.GetRectangle(out left, out top, out right, out bottom);

                int flags = GetClickFlags();
                uiElem.Click(2, 2, flags);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }