private void DispatcherTimerTick(object sender, EventArgs e) { var screenPos = Mouse.Position; try { var hoveredElement = _automation.FromPoint(screenPos); if (hoveredElement != null && hoveredElement.Properties.ProcessId != _targetProcessId) { return; } if (!Equals(_currentHoveredElement, hoveredElement)) { _currentHoveredElement = hoveredElement; ElementHovered?.Invoke(this, hoveredElement); HighlightElement(hoveredElement); } } catch { _currentHoveredElement = null; } }
private void DispatcherTimerTick(object sender, EventArgs e) { if (System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control)) { var screenPos = Mouse.Position; try { var hoveredElement = _automation.FromPoint(screenPos); // Skip items in the current process // Like Inspect itself or the overlay window if (hoveredElement.Properties.ProcessId == Process.GetCurrentProcess().Id) { return; } if (!Equals(_currentHoveredElement, hoveredElement)) { _currentHoveredElement = hoveredElement; ElementHovered?.Invoke(hoveredElement); } else { ElementHighlighter.HighlightElement(hoveredElement); } } catch (UnauthorizedAccessException) { string caption = "FlaUInspect - Unauthorized access exception"; string message = "You are accessing a protected UI element in hover mode.\nTry to start FlaUInspect as administrator."; MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private void DispatcherTimerTick(object sender, EventArgs e) { if (System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control)) { var screenPos = Mouse.Position; var hoveredElement = _automation.FromPoint(screenPos); // Skip items in the current process // Like Inspect itself or the overlay window if (hoveredElement.Current.ProcessId == Process.GetCurrentProcess().Id) { return; } if (!Equals(_currentHoveredElement, hoveredElement)) { _currentHoveredElement = hoveredElement; ElementHovered?.Invoke(hoveredElement); } else { ElementHighlighter.HighlightElement(hoveredElement); } } }