示例#1
0
        private async void PasteFromClipboard(TextItem textItem)
        {
            try
            {
                if (textItem == null)
                {
                    return;
                }

                _window.HideWithPrevStatePreserved();

                await System.Threading.Tasks.Task.Run(() => System.Threading.Thread.Sleep(200));

                IntPtr targetWindow = await Win32Wrapper.PasteText(textItem.Text, KeepOnClipboardAfterInsert);

                _window.ShowWithPreservedState();

                Win32Wrapper.SetForegroundWindow(targetWindow);
            }
            catch (Exception ex)
            {
                string error = Localization.TranslationManager.Instance.TranslateString("ErrorMessagePasterFromClipboard");
                LogHelper.LogException(ex, error);
                _confirmer.ConfirmStop(error);
            }
        }
示例#2
0
        private void PerformHotSampling()
        {
            if (_newWidthBox.Value < 100 || _newHeightBox.Value < 100)
            {
                return;
            }
            if ((Win32Wrapper.IsIconic(_gameWindowHwnd) || Win32Wrapper.IsZoomed(_gameWindowHwnd)))
            {
                Win32Wrapper.ShowWindow(_gameWindowHwnd, Win32Wrapper.SW_SHOWNOACTIVATE);
            }

            int newHorizontalResolution = (int)_newWidthBox.Value;
            int newVerticalResolution   = (int)_newHeightBox.Value;
            // always set the window at (0,0), if width is >= screen width.
            var  screenBounds = Screen.FromHandle(_gameWindowHwnd).Bounds;
            uint uFlags       = Win32Wrapper.SWP_NOZORDER | Win32Wrapper.SWP_NOACTIVATE | Win32Wrapper.SWP_NOOWNERZORDER | Win32Wrapper.SWP_NOSENDCHANGING;

            if (newHorizontalResolution < screenBounds.Width)
            {
                // let the window be where it is.
                uFlags |= Win32Wrapper.SWP_NOMOVE;
            }

            Win32Wrapper.SetWindowPos(_gameWindowHwnd, 0, 0, 0, newHorizontalResolution, newVerticalResolution, uFlags);
            if (GameSpecificConstants.HotsamplingRequiresEXITSIZEMOVE)
            {
                // A warning of unreachable code will be raised here, that's ok. this code is only used when the constant is true
                Win32Wrapper.SendMessage(_gameWindowHwnd, Win32Wrapper.WM_EXITSIZEMOVE, 0, 0);
            }

            LogHandlerSingleton.Instance().LogLine("Switching resolution on window with hwnd 0x{0} to resolution {1}x{2}", "Hotsampler", _gameWindowHwnd.ToString("x"),
                                                   newHorizontalResolution, newVerticalResolution);

            // remove / add borders
            uint nStyle = (uint)Win32Wrapper.GetWindowLong(_gameWindowHwnd, Win32Wrapper.GWL_STYLE);

            nStyle = (nStyle | (Win32Wrapper.WS_THICKFRAME + Win32Wrapper.WS_DLGFRAME + Win32Wrapper.WS_BORDER + Win32Wrapper.WS_MAXIMIZEBOX + Win32Wrapper.WS_MINIMIZEBOX));
            if (_useWindowBordersCheckBox.IsChecked == false)
            {
                nStyle ^= (Win32Wrapper.WS_THICKFRAME + Win32Wrapper.WS_DLGFRAME + Win32Wrapper.WS_BORDER + Win32Wrapper.WS_MAXIMIZEBOX + Win32Wrapper.WS_MINIMIZEBOX);
            }
            Win32Wrapper.SetWindowLong(_gameWindowHwnd, Win32Wrapper.GWL_STYLE, nStyle);
            uFlags = Win32Wrapper.SWP_NOSIZE | Win32Wrapper.SWP_NOMOVE | Win32Wrapper.SWP_NOZORDER | Win32Wrapper.SWP_NOACTIVATE | Win32Wrapper.SWP_NOOWNERZORDER | Win32Wrapper.SWP_NOSENDCHANGING | Win32Wrapper.SWP_FRAMECHANGED;
            Win32Wrapper.SetWindowPos(_gameWindowHwnd, 0, 0, 0, 0, 0, uFlags);

            // Send the resize viewport message to the dll so it can resize the viewport based on the new resolution. The game itself won't resize the viewport on its own.
            MessageHandlerSingleton.Instance().SendResizeViewportAction(newHorizontalResolution, newVerticalResolution);

            AddResolutionToRecentlyUsedList(newHorizontalResolution, newVerticalResolution);

            if (_switchAfterResizingCheckBox.IsChecked == true)
            {
                // focus the attached application's window
                Win32Wrapper.SetForegroundWindow(_gameWindowHwnd);
            }
        }
 private void _switchToGameWindowButton_OnClick(object sender, RoutedEventArgs e)
 {
     // focus the attached application's window
     Win32Wrapper.SetForegroundWindow(_gameWindowHwnd);
 }