Example #1
0
        public async Task SendWindowModeCommandAsync()
        {
            bool    isFullScreen           = _windowModeMonitor.IsForegroundFullScreen();
            Process leagueOfLegendsProcess = Process.GetProcessesByName(LeagueClientProcess).First();

            bool isCurrentFullScreen = isFullScreen;

            do
            {
                await Task.Run(async() =>
                {
                    SetForegroundWindow(leagueOfLegendsProcess.MainWindowHandle);
                    if (isCurrentFullScreen)
                    {
                        await Task.Delay(5000);
                    }

                    //simulate double-keypress
                    SendInputWrapper.SendKey(_initializerToUShortMapper.Map(Initializer.Alt), press: true);
                    await Task.Delay(10);
                    SendInputWrapper.SendKey(_initializerToUShortMapper.Map(Initializer.Enter), press: true);
                    await Task.Delay(10);
                    SendInputWrapper.SendKey(_initializerToUShortMapper.Map(Initializer.Enter), press: false);
                    await Task.Delay(10);;
                    SendInputWrapper.SendKey(_initializerToUShortMapper.Map(Initializer.Alt), press: false);
                    await Task.Delay(3000);

                    isCurrentFullScreen = _windowModeMonitor.IsForegroundFullScreen();
                });
            } while (isCurrentFullScreen == isFullScreen);
        }
        private bool ShouldUpdateScreenMode(ScreenMode screenMode)
        {
            bool isFullScreen = _windowModeMonitor.IsForegroundFullScreen();

            return(screenMode == ScreenMode.FullScreen && !isFullScreen || screenMode == ScreenMode.WindowMode && isFullScreen);
        }