private void button1_Click(object sender, EventArgs e) { TSelectionInfo tSelInfo = null; this.WindowState = FormWindowState.Minimized; try { tSelInfo = (TSelectionInfo)m_tSelection.Start((int)TS_SELECTION.tsSelectionWindow, (int)TS_SELECTION_OPTIONS.tsSelFlagDefaultText); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } UIElem uiElem = null; try { uiElem = ComFactory.Instance.NewUIElem(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } // get the hwnd uiElem.hwnd = tSelInfo.WindowHandle; string strID = uiElem.GetID(false); txtID.Text = strID; txtHandle.Text = uiElem.hwnd.ToString("X"); int x1, y1, x2, y2; try { // get the rectangle uiElem.GetRectangle(out x1, out y1, out x2, out y2); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } // show the points txtX.Text = "0"; txtY.Text = "0"; txtWidth.Text = (x2 - x1).ToString(); txtHeight.Text = (y2 - y1).ToString(); this.WindowState = FormWindowState.Normal; }
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; }
private void btnCollect_Click(object sender, EventArgs e) { m_bRegOrWnd = true; this.WindowState = FormWindowState.Minimized; System.Threading.Thread.Sleep(100); TSelectionInfo tSelInfo = null; try { tSelInfo = (TSelectionInfo)m_tSelection.Start( (int)TS_SELECTION.tsSelectionRectangle, (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"); UIElem uiElem = ComFactory.Instance.NewUIElem(); uiElem.hwnd = hwnd; // set the UI element ID textBox1.Text = uiElem.GetID(true); // get the selection points tSelInfo.GetClientCoordinates(); // set the points txtX.Text = tSelInfo.RCLeft.ToString(); txtY.Text = tSelInfo.RCTop.ToString(); txtWidth.Text = tSelInfo.RCWidth.ToString(); txtHeight.Text = tSelInfo.RCHeight.ToString(); //PerformRegionCapture(hwnd, x1, y1, width, height); this.WindowState = FormWindowState.Normal; }
private void btnCollect_Click(object sender, EventArgs e) { TSelectionInfo tSelInfo = null; this.WindowState = FormWindowState.Minimized; try { tSelInfo = (TSelectionInfo)m_tSelection.Start((int)TS_SELECTION.tsSelectionRectangle, (int)TS_SELECTION_OPTIONS.tsSelFlagDefaultText); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } tSelInfo.GetClientCoordinates(); int hwnd = tSelInfo.WindowHandle; string strID = null; UIElem uiElem = null; try { uiElem = ComFactory.Instance.NewUIElem(); uiElem.hwnd = hwnd; strID = uiElem.GetID(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } txtHandle.Text = hwnd.ToString("X"); txtX.Text = tSelInfo.RCLeft.ToString(); txtY.Text = tSelInfo.RCTop.ToString(); txtWidth.Text = tSelInfo.RCWidth.ToString(); txtHeight.Text = tSelInfo.RCHeight.ToString(); txtID.Text = strID; this.WindowState = FormWindowState.Normal; }