Exemple #1
0
        private void SetControl(WinPosition pos)
        {
            if (Visibility == Visibility.Hidden)
            {
                Visibility = Visibility.Visible;
                Topmost    = true;
            }

            Left = pos.Right - Width - Settings.Default.RightOffsetPx;
            Top  = pos.Bottom - Height / 2 - Settings.Default.BottomOffsetPx;
        }
        private void BtnGetOpenedWindows_OnClick(object sender, RoutedEventArgs e)
        {
            _monitorCheckTimer.Elapsed += OnMonitorCheck;
            _monitorCheckTimer.Start();

            //return;
            WinPosition.GetMonitorCount();
            foreach (KeyValuePair <IntPtr, string> window in _winPosition.GetOpenWindows())
            {
                IntPtr handle = window.Key;
                string title  = window.Value;

                var windowRect = new Rectangle();
                User32Wrapper.GetWindowRect(handle, ref windowRect);

                lstBox.Items.Add($"{handle}: {title} : {windowRect}");
                if (title.Contains("iTunes"))
                {
                    User32Wrapper.SetWindowPos(handle, (IntPtr)SpecialWindowHandles.HWND_TOP, windowRect.Left + 1000,
                                               windowRect.Top + 100, windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top,
                                               SetWindowPosFlags.ShowWindow);
                }
            }
        }