Exemple #1
0
        private async void OnGameExited(object sender, ProcessEventArgs e)
        {
            if (SetHnd.Options.MinimizeLauncher && LauncherPL.ProcWrapper.IsRunning())
            {
                WindowUtils.MinimizeWindow(LauncherPL.ProcWrapper.Hwnd);
            }

            // run PostGameExecPath/Args after the game exits
            PostGamePL = new ProcessLauncher(
                SetHnd.Paths.PostGameExecPath,
                SetHnd.Paths.PostGameExecArgs,
                elevate: SetHnd.Options.ElevateExternals,
                delayTime: SetHnd.Options.PostGameWaitTime
                );
            await PostGamePL.Launch();

            if (SetHnd.Options.PostGameWaitTime > 0)
            {
                ProcessUtils.Logger("OSOL", $"Game exited, moving on to clean up after {SetHnd.Options.PostGameWaitTime}s...");
            }
            else
            {
                ProcessUtils.Logger("OSOL", $"Game exited, cleaning up...");
            }
            await Task.Delay(SetHnd.Options.PostGameWaitTime * 1000);

            if (SetHnd.Options.CloseLauncher && ProcessWrapper.IsRunningByName(LauncherName))
            {
                ProcessUtils.Logger("OSOL", $"Found launcher still running, killing it...");
                ProcessWrapper.KillProcTreeByName(LauncherName);
            }

            OnClosing();
        }
Exemple #2
0
        public async Task ProcessLauncher()
        {
            // check for running instance of launcher (relaunch if required)
            if (SetHnd.Options.ReLaunch && LauncherPathValid && ProcessWrapper.IsRunningByName(LauncherName))
            {// if the launcher is running before the game kill it so we can run it through Steam
                ProcessUtils.Logger("OSOL", $"Found previous instance of launcher [{LauncherName}.exe], relaunching...");
                ProcessWrapper.KillProcTreeByName(LauncherName);
            }

            // run PreLaunchExecPath/Args before the launcher
            PreLauncherPL = new ProcessLauncher(
                SetHnd.Paths.PreLaunchExecPath,
                SetHnd.Paths.PreLaunchExecArgs,
                elevate: SetHnd.Options.ElevateExternals
                );
            await PreLauncherPL.Launch();

            LauncherPL = new ProcessLauncher(
                SetHnd.Paths.LauncherPath,
                SetHnd.Paths.LauncherArgs,
                avoidProcName: GameName
                );

            if (!SetHnd.Options.SkipLauncher && SetHnd.Options.ReLaunch)
            {
                await LauncherPL.Launch(); // launching the launcher is optional
            }
            LauncherMonitor = new ProcessMonitor(
                LauncherPL,
                SetHnd.Options.ProcessAcquisitionTimeout,
                SetHnd.Options.InterProcessAcquisitionTimeout
                );
            LauncherMonitor.ProcessHardExit += OnLauncherExited;

            // signal for manual game launch
            if (SetHnd.Options.SkipLauncher)
            {
                OnLauncherAcquired(this, null);
            }
            else
            {
                LauncherMonitor.ProcessAcquired += OnLauncherAcquired;
            }

            // wait for all running threads to exit
            while (!ExitRequested ||
                   PreLauncherPL != null && PreLauncherPL.ProcWrapper.IsRunning() ||
                   PostGamePL != null && PostGamePL.ProcWrapper.IsRunning() ||
                   LauncherMonitor != null && LauncherMonitor.IsRunning() ||
                   GameMonitor != null && GameMonitor.IsRunning())
            {
                await Task.Delay(1000);
            }
        }