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 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); } }