private void HandleTimerTick(object sender, EventArgs e) { // Simulate a mouse move over this point to activate any important mouseover behaviors System.Windows.Point point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y); AutomationElement element = null; try { element = AutomationElement.FromPoint(new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y)); } catch { } if (element != null) { /*if( !element.Equals( capturedElement ) ) * GDI32.RedrawWindow(capturedElement);*/ UIControlBase control = UIAControl.GetControlByType(element); if (control != null) { Debug.WriteLine("Sending MOUSEMOVE"); System.Windows.Point clientPoint = new System.Windows.Point((int)(Cursor.Position.X - control.Layout.X), (int)(Cursor.Position.Y - control.Layout.Y)); SendMessage(new HandleRef(this, control.Handle), 0x0200, (IntPtr)0, (IntPtr)(((int)clientPoint.Y << 16) | (int)clientPoint.X)); } Debug.WriteLine("Repainting highlight after MOUSEMOVE"); GDI32.HighlightWindow(capturedElement); } RecaptureElement(point, true); }
private void ShowCapturedElement() { if (capturedElement == null) { return; } UIControlBase control = null; if (radioButtonWeb.Checked) { control = Desktop.Web.GetControlFromCursor(); } else { control = UIAControl.GetControlByType(capturedElement); } if (control != null) { textBox.Text = control.CodePath; coordinate = new System.Windows.Point((int)(Cursor.Position.X - control.Layout.X), (int)(Cursor.Position.Y - control.Layout.Y)); textBoxXY.Text = coordinate.ToString(); _controlPropertyGrid.SelectedObject = null; _hierarchyList.BeginUpdate(); _hierarchyList.Items.Clear(); UIControlBase pass = control; while (pass != null) { _hierarchyList.Items.Add(new ListViewItem() { Text = pass.VisibleName, Tag = pass }); pass = pass.Parent; } _hierarchyList.EndUpdate(); _hierarchyList.Items[0].Selected = true; } }
public UIControlBase GetFocusedElement() { return(UIAControl.GetControlByType(AutomationElement.FocusedElement)); }
/// <summary> /// Set focus on current page. /// </summary> /// <example> /// <code> /// Desktop.Web.CurrentPage.Navigate("www.amazon.com"); /// bool pageFound = Desktop.Web.WaitForPage("amazon", 30,true); /// if (pageFound) /// Desktop.Web.CurrentPage.SetFocus(); /// </code> /// </example> public override void SetFocus() { UIAControl.GetControlByType(uiaElement).SetFocus(); docInstance.focus(); }