Ejemplo n.º 1
0
        private void FindRa3Process()
        {
            var ra3Procs = Process.GetProcessesByName(Constants.Ra3ProcessName);

            if (ra3Procs.Length <= 0)
            {
                Logger.Debug("RA3 *not* found at startup.");
                return;
            }

            if (Pinvokes.IsWindow(ra3Procs[0].MainWindowHandle))
            {
                Logger.Debug("RA3 found at startup.");
                LatestRa3 = ra3Procs[0];
                return;
            }

            Task.Delay(1000).ContinueWith(_ =>
            {
                Logger.Debug("RA3 found but no window yet. Retry.");
                FindRa3Process();
            });
        }
Ejemplo n.º 2
0
        private void ProcessWatcherOnProcessStarted(object sender, ProcessArgs e)
        {
            Console.WriteLine($"[{e.Process.ProcessName}] LAUNCHED");

            if (e.Process.ProcessName != Constants.Ra3ProcessName)
            {
                return;
            }

            Logger.Debug($"Found ra3 process - Has Window: {Pinvokes.IsWindow(e.Process.MainWindowHandle)}");

            // Right after process creation, ra3 doesnt have a window and it can be assumed that the process is not fully loaded.
            // This is a workaround which will probably remain here forever :/
            if (!Pinvokes.IsWindow(e.Process.MainWindowHandle))
            {
                Task.Delay(1000).ContinueWith(_ => { ProcessWatcherOnProcessStarted(sender, e); });
                return;
            }

            if (LatestRa3 == null || LatestRa3.HasExited)
            {
                LatestRa3 = e.Process;
            }
        }