Exemplo n.º 1
0
        public static void Launch()
        {
            //Checking for existing Gw2 instances. Do not continue until closed.
            //if (Process.GetProcesses().ToList().Where(a => !nomutexpros.Contains(a.Id) && a.ProcessName == Regex.Replace(exename, @"\.exe(?=[^.]*$)", "", RegexOptions.IgnoreCase)).Any())

            LoadingWindow.Start("Launching Game");

            if (!ClientManager.ClientReg.CheckRegClients())
            {
                MessageBox.Show("At least one instance of Guild Wars is running that was not opened by LaunchBuddy. That instance needs to be closed.");
                return;
                //HandleManager.ClearMutex(exename, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros);
            }


            if (Gw2_Launchbuddy.Properties.Settings.Default.useinstancegui)
            {
                if (Globals.Appmanager != null && Globals.Appmanager.Visibility == Visibility.Visible)
                {
                    Globals.Appmanager.Topmost = true;
                    Globals.Appmanager.Focus();
                    Globals.Appmanager.WindowState = WindowState.Normal;
                }
                else
                {
                    Globals.Appmanager.Show();
                }
            }

            //Launching the application with arguments
            if (AccountManager.SelectedAccountCollection.Count > 0)
            {
                foreach (var Account in AccountManager.SelectedAccountCollection)
                {
                    LaunchGW2(Account);
                }
            }
            else
            {
                LaunchGW2(AccountManager.DefaultAccount);
            }

            GFXManager.RestoreDefault();

            //Launching AddOns
            try
            {
                AddOnManager.LaunchAll();
            }
            catch (Exception err)
            {
                MessageBox.Show("One or more AddOns could not be launched.\n" + err.Message);
            }

            LoadingWindow.Stop();
        }
Exemplo n.º 2
0
        public static async Task launch_click()
        {
            //Checking for existing Gw2 instances. Do not continue until closed.
            //if (Process.GetProcesses().ToList().Where(a => !nomutexpros.Contains(a.Id) && a.ProcessName == Regex.Replace(exename, @"\.exe(?=[^.]*$)", "", RegexOptions.IgnoreCase)).Any())
            if (!checkRegClients())
            {
                MessageBox.Show("At least one instance of Guild Wars is running that was not opened by LaunchBuddy. That instance will need to be closed.");
                return;
                //HandleManager.ClearMutex(exename, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros);
            }

            if (Gw2_Launchbuddy.Properties.Settings.Default.useinstancegui)
            {
                if (Globals.Appmanager != null && Globals.Appmanager.Visibility == Visibility.Visible)
                {
                    Globals.Appmanager.Topmost = true;
                    Globals.Appmanager.Focus();
                    Globals.Appmanager.WindowState = WindowState.Normal;
                }
                else
                {
                    Globals.Appmanager.Show();
                }
            }

            //Launching the application with arguments
            if (Globals.selected_accs.Count > 0)
            {
                var delayValue = Properties.Settings.Default.delaybetweeninstaces
                    ? Properties.Settings.Default.secondsbetweeninstances * 1000 : 0;
                for (int i = 0; i <= Globals.selected_accs.Count - 1; i++)
                {
                    await launchgw2(i, i *delayValue);
                }
            }
            else
            {
                await launchgw2();
            }

            GFXManager.RestoreDefault();

            //Launching AddOns
            try
            {
                AddOnManager.LaunchAll();
            }
            catch (Exception e) // logged
            {
                Log.Error("Unable to launch add ons", e);
                MessageBox.Show($"Add-Ons are causing problems. We were unable to launch at least one of them. See log for more info.\nMore Technical information:\n{e}");
            }
        }
Exemplo n.º 3
0
        public static void launch_click()
        {
            //Checking for existing Gw2 instances. Do not continue until closed.
            //if (Process.GetProcesses().ToList().Where(a => !nomutexpros.Contains(a.Id) && a.ProcessName == Regex.Replace(exename, @"\.exe(?=[^.]*$)", "", RegexOptions.IgnoreCase)).Any())
            if (!checkRegClients())
            {
                MessageBox.Show("At least one instance of Guild Wars is running that was not opened by LaunchBuddy. That instance will need to be closed to make Launchbuddy work properly!");
                //return;
                //HandleManager.ClearMutex(exename, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros);
            }

            if (Gw2_Launchbuddy.Properties.Settings.Default.useinstancegui)
            {
                if (Globals.Appmanager != null && Globals.Appmanager.Visibility == Visibility.Visible)
                {
                    Globals.Appmanager.Topmost = true;
                    Globals.Appmanager.Focus();
                    Globals.Appmanager.WindowState = WindowState.Normal;
                }
                else
                {
                    Globals.Appmanager.Show();
                }
            }

            //Launching the application with arguments
            if (Globals.selected_accs.Count > 0)
            {
                for (int i = 0; i <= Globals.selected_accs.Count - 1; i++)
                {
                    launchgw2(i);
                }
            }
            else
            {
                launchgw2();
            }

            GFXManager.RestoreDefault();

            //Launching AddOns
            try
            {
                AddOnManager.LaunchAll();
            }
            catch (Exception err)
            {
                MessageBox.Show("One or more AddOns could not be launched.\n" + err.Message);
            }
        }
Exemplo n.º 4
0
 static async Task launchgw2(int?accnr = null, int delay = 0)
 {
     try
     {
         if (delay > 0)
         {
             await Task.Delay(delay);
         }
         ProcessStartInfo gw2proinfo = new ProcessStartInfo();
         gw2proinfo.FileName         = Globals.exepath + Globals.exename;
         gw2proinfo.Arguments        = Globals.args.Print(accnr);
         gw2proinfo.WorkingDirectory = Globals.exepath;
         Process gw2pro = new Process {
             StartInfo = gw2proinfo
         };
         if (accnr != null)
         {
             Globals.LinkedAccs.Add(new ProAccBinding(gw2pro, Globals.selected_accs[(int)accnr]));
             GFXManager.UseGFX(Globals.selected_accs[(int)accnr].Configpath);
         }
         else
         {
             MainWindow.Account undefacc = new MainWindow.Account {
                 Email = "-", Nick = "Acc Nr" + Globals.LinkedAccs.Count
             };
             Globals.LinkedAccs.Add(new ProAccBinding(gw2pro, undefacc));
         }
         try
         {
             gw2pro.Start();
         }
         catch (Exception err) // logged
         {
             Log.Error($"Unable to launch GW2. Process info: (Filename:{gw2pro.StartInfo.FileName}|Working Directory:{gw2pro.StartInfo.WorkingDirectory}). Arguments not logged for security reasons.", err);
             MessageBox.Show($"Guild Wars 2 does not seem to be working. Maybe the path is wrong?\nMore technical information:\n{err}");
             throw;
         }
         var mutexName       = "AN-Mutex-Window-Guild Wars 2";
         var exProcIDsString =
             nomutexpros == null
             ? string.Empty
             : string.Join(",", nomutexpros.Select(id => id.ToString().ToArray()));
         var processStartInfoString = $"(Proc:{Globals.exename}|Mutex name:{mutexName}|excProcIDs:{exProcIDsString})";
         try
         {
             HandleManager.ClearMutex(Globals.exename, mutexName, ref nomutexpros);
         }
         catch (Exception err) // logged
         {
             Log.Error($"Unable to clear Mutex. {processStartInfoString}", err);
             MessageBox.Show($"Something went wrong while we tried to trick GW2 into allowing a second instance. Bummer.\nMore technical information:\n{err}");
             throw;
         }
         try
         {
             gw2pro.WaitForInputIdle(10000);
         }
         catch (Exception err) // logged
         {
             Log.Error($"Error while waiting for idle input from GW2 process.", err);
             MessageBox.Show($"Guild Wars 2 seems to be stuck. Are you on a very old computer?\nMore technical information:\n{err}");
             throw;
         }
         string processMD5String = null;
         try
         {
             processMD5String = procMD5(gw2pro);
         }
         catch (Exception e) // logged
         {
             Log.Error($"Unable to get process MD5. Process Start Info: {processStartInfoString}", e);
             MessageBox.Show($"Something went wrong trying to get more info from the GW2 process. What is happening, dude?\nMore technical information:\n{e}");
             throw;
         }
         try
         {
             //Register the new client to prevent problems.
             updateRegClients(procMD5(gw2pro));
         }
         catch (Exception err) // logged
         {
             Log.Error($"Unable to register the new client. Process MD5: {processMD5String}", err);
             MessageBox.Show($"Something went sideways while we were trying to prevent future issues. Isn't that ironic?\nMore technical information:\n{err}");
             throw;
         }
         Thread.Sleep(3000);
         if (Properties.Settings.Default.use_reshade)
         {
             var reshadeUnlockerProcess   = GetReshadeUnlockerProcess();
             var reshadeUnlockerStartInfo = $"(Filename:{reshadeUnlockerProcess.FileName}|Working Directory:{reshadeUnlockerProcess.WorkingDirectory})";
             try
             {
                 Process.Start(reshadeUnlockerProcess);
             }
             catch (Exception err) // logged
             {
                 Log.Error($"Unable to register the new client. Process MD5: {processMD5String}", err);
                 MessageBox.Show($"Reshade Unlocker does not seem to be working. Maybe the path is wrong?\nMore technical information:\n{err}");
                 throw;
             }
         }
     }
     catch // logged
     {
         MessageBox.Show("Something went wrong trying to launch Gw2. See log file for more information.");
     }
 }
Exemplo n.º 5
0
        static void launchgw2(int?accnr = null)
        {
            try
            {
                ProcessStartInfo gw2proinfo = new ProcessStartInfo();
                gw2proinfo.FileName         = Globals.exepath + Globals.exename;
                gw2proinfo.Arguments        = Globals.args.Print(accnr);
                gw2proinfo.WorkingDirectory = Globals.exepath;
                Process gw2pro = new Process {
                    StartInfo = gw2proinfo
                };
                if (accnr != null)
                {
                    Globals.LinkedAccs.Add(new ProAccBinding(gw2pro, Globals.selected_accs[(int)accnr]));
                    GFXManager.UseGFX(Globals.selected_accs[(int)accnr].Configpath);
                }
                else
                {
                    MainWindow.Account undefacc = new MainWindow.Account {
                        Email = "-", Nick = "Acc Nr" + Globals.LinkedAccs.Count
                    };
                    Globals.LinkedAccs.Add(new ProAccBinding(gw2pro, undefacc));
                }

                try
                {
                    gw2pro.Start();
                }
                catch (Exception err)
                {
                    System.Windows.MessageBox.Show("Could not launch Gw2. Invalid path?\n" + err.Message);
                }
                try
                {
                    HandleManager.ClearMutex(Globals.exename, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros);
                    gw2pro.WaitForInputIdle(10000);
                    //Thread.Sleep(1000);
                    //Register the new client to prevent problems.
                    updateRegClients(procMD5(gw2pro));
                    Thread.Sleep(3000);
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }

                if (Properties.Settings.Default.use_reshade)
                {
                    try
                    {
                        ProcessStartInfo unlockerpro = new ProcessStartInfo();
                        unlockerpro.FileName         = Globals.unlockerpath;
                        unlockerpro.WorkingDirectory = Path.GetDirectoryName(Globals.unlockerpath);
                        Process.Start(unlockerpro);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("Could not launch ReshadeUnlocker. Invalid path?\n" + err.Message);
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }