コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TSelectionInfo tSelInfo = null;

            this.WindowState = FormWindowState.Minimized;
            try
            {
                tSelInfo = (TSelectionInfo)m_tSelection.Start((int)TS_SELECTION.tsSelectionUIElement, (int)TS_SELECTION_OPTIONS.tsSelFlagDefaultText);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            this.WindowState = FormWindowState.Normal;
            string strID  = null;
            UIElem uiElem = null;

            try
            {
                uiElem = ComFactory.Instance.NewUIElem();
                uiElem.InitializeFromID(tSelInfo.UIElementID, false);
                strID = tSelInfo.UIElementID;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            txtHandle.Text = uiElem.hwnd.ToString("X");
            txtID.Text     = strID;
        }
コード例 #2
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);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            m_bRegOrWnd = false;

            TSelectionInfo tSelInfo = null;

            this.WindowState = FormWindowState.Minimized;
            System.Threading.Thread.Sleep(100);

            try
            {
                tSelInfo = (TSelectionInfo)m_tSelection.Start(
                    (int)TS_SELECTION.tsSelectionUIElement,
                    (int)TS_SELECTION_OPTIONS.tsSelFlagDefaultText
                    );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            // get the hwnd
            int hwnd = tSelInfo.WindowHandle;

            txtHandle.Text = hwnd.ToString("X");

            // set the UI element ID
            UIElem uiElem = ComFactory.Instance.NewUIElem();

            if (tSelInfo.UIElementID == "")
            {
                textBox1.Text    = "A valid ID could not be generated!";
                this.WindowState = FormWindowState.Normal;

                return;
            }
            try
            {
                uiElem.InitializeFromID(tSelInfo.UIElementID, true);
                string uiElemID = uiElem.GetID(false);
                textBox1.Text = uiElemID;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.WindowState = FormWindowState.Normal;
        }
コード例 #5
0
        private void btnRectangle_Click(object sender, EventArgs e)
        {
            int x      = int.Parse(txtX.Text);
            int y      = int.Parse(txtY.Text);
            int width  = int.Parse(txtWidth.Text);
            int height = int.Parse(txtHeight.Text);

            UIElem uiElem = null;

            try
            {
                uiElem = ComFactory.Instance.NewUIElem();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (checkIDorHWND.Checked == true)
            {
                // get id
                string strID = textBox1.Text;
                try
                {
                    uiElem.InitializeFromID(strID, true);
                    m_bCanTryAgain = true;
                    PerformRegionCapture(uiElem.hwnd, x, y, width, height);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                // get the hwnd
                int hwnd = int.Parse(txtHandle.Text, System.Globalization.NumberStyles.HexNumber);
                m_bCanTryAgain = true;
                PerformRegionCapture(hwnd, x, y, width, height);
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            UIElem uiElem = null;

            try
            {
                uiElem = ComFactory.Instance.NewUIElem();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (checkIDorHWND.Checked == true)
            {
                // get id
                string strID = textBox1.Text;
                try
                {
                    uiElem.InitializeFromID(strID, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                // get the hwnd
                int hwnd = int.Parse(txtHandle.Text, System.Globalization.NumberStyles.HexNumber);
                uiElem.hwnd = hwnd;
            }

            m_bCanTryAgain = true;
            PerformWndCapture(uiElem);
        }