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 0x0202: { //LButtonUp form.Visible = true; _timer.Stop(); User32.ReleaseCapture(); GDI32.RedrawWindow(capturedElement); Cursor = Cursors.Default; btnCursor.BackgroundImage = Properties.Resources.Crosshair; capturing = false; ShowCapturedElement(); break; } case 0x0200: { //MouseMove System.Windows.Point point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y); RecaptureElement(point, true); } break; default: break; } } base.WndProc(ref m); }
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); }