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 RecaptureElement(System.Windows.Point point, bool highlight) { AutomationElement element = null; try { // Recapture element in case things have changed element = AutomationElement.FromPoint(point); } catch { } if (highlight && element != null && !element.Equals(capturedElement)) { Debug.WriteLine("Changing highlighted element"); GDI32.RedrawWindow(capturedElement); GDI32.HighlightWindow(element); // Restart the timer to give a second's delay before delivering the mouse move _timer.Stop(); _timer.Start(); } capturedElement = element; }
protected override void WndProc(ref Message m) { if (capturing) { switch (m.Msg) { case (int)QAliber.Recorder.Structures.MouseMessages.WM_LBUTTONUP: User32.ReleaseCapture(); GDI32.RedrawWindow(capturedElement); Cursor = Cursors.Default; toolStripCapture.Image = Resources.Crosshair; hotkey_HotkeyPressed(this, EventArgs.Empty); capturing = false; break; case (int)QAliber.Recorder.Structures.MouseMessages.WM_MOUSEMOVE: try { AutomationElement element = AutomationElement.FromPoint(new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y)); if (!element.Equals(capturedElement)) { GDI32.RedrawWindow(capturedElement); GDI32.HighlightWindow(element); capturedElement = element; } } catch { } break; default: break; } } base.WndProc(ref m); }