private void ClickManagerWindow_OnLoaded(object sender, RoutedEventArgs e) { var timer = new System.Windows.Threading.DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 100), IsEnabled = true }; timer.Tick += (o, t) => { if (_targetWindow != IntPtr.Zero) { WindowService.GetWindowRect(_targetWindow, out Rectangle rect); Point cursorPoint = new Point(); VirtualMouse.GetCursorPos(ref cursorPoint); _leftTop = new Point(rect.X, rect.Y); ActiveWindowInfo.Text = $"{_windowHeader}: " + $"{_leftTop}, {_width} x {_height}"; XTextBlock.Text = (cursorPoint.X - _leftTop.X).ToString(); YTextBlock.Text = (cursorPoint.Y - _leftTop.Y).ToString(); if (_width != rect.Width - rect.X || _height != rect.Height - rect.Y) { _width = rect.Width - rect.X; _height = rect.Height - rect.Y; UpdateActions(); ActionsGrid.ItemsSource = Actions; SetBoltIconCoords(); SetSettingsIconCoords(); } } else { SetElementsState(false); } }; timer.Start(); }