Beispiel #1
0
        private static void launchWinapi(string id)
        {
            GOGGalaxy.open(id);

            IntPtr hwnd = GOGGalaxy.waitForStartup();

            WinAPI.SetForegroundWindow(hwnd);
            WinAPI.Click(hwnd, new System.Drawing.Point(_x, _y));
        }
Beispiel #2
0
        public static void launch(string id, Action callback = null)
        {
            // GOGGalaxy.launchWinapi(id); // old hacky way

            Process.Start(GOGRegistry.ClientExecutable, $@"/gameid {id} /command runGame");
            GOGGalaxy.waitForStartup();

            GOGGame game = GOGRegistry.Game(id);

            if (game?.ExecutableName?.Length > 0)
            {
                Thread.Sleep(5000);

                Process[] procs = Process.GetProcessesByName(game.ExecutableName.Replace(".exe", ""));

                if (procs?.Length > 0)
                {
                    procs[0].WaitForExit();
                }

                Thread.Sleep(5000);

                procs = Process.GetProcesses();

                foreach (Process proc in procs)
                {
                    try
                    {
                        if (normalize(proc.MainModule.FileName).StartsWith(normalize(game.Path)))
                        {
                            proc.WaitForExit();
                            break;
                        }
                    }
                    catch {}
                }
            }

            callback?.Invoke();
        }