示例#1
0
        void diabloProcess_Exited(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                try
                {
                    this.Invoke(new ProcessExitedDelegate(diabloProcess_Exited), sender, e);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                diabloPanel.ReleaseDiabloWindow();

                if (diabloWindow != null)
                {
                    diabloWindow.Close();
                    diabloWindow = null;
                }

                ConsoleTab.WriteLine("Closed " + ((Process)sender).StartInfo.FileName);
            }
        }
示例#2
0
        public void LoadDiablo2(int loginDelay)
        {
            if (diabloWindow == null)
            {
                if (!string.IsNullOrEmpty(exePath) && System.IO.File.Exists(exePath))
                {
                    Process          diabloProcess = new Process();
                    ProcessStartInfo info          = new ProcessStartInfo();
                    info.FileName  = exePath;
                    info.Arguments = "-w -ns";

                    // Crap Fett007 added to bring master variable
                    string username = string.Empty;
                    string password = string.Empty;
                    string charslot = string.Empty;
                    string master   = string.Empty;

                    foreach (string accountString in BlueVex2.Properties.Settings.Default.Accounts)
                    {
                        if (accountString.StartsWith(defaultAccount + ","))
                        {
                            string[] parts = accountString.Split(',');
                            username = parts[0];
                            password = parts[1];
                            charslot = parts[2];
                            master   = parts[3];
                        }
                    }


                    switch (master)
                    {
                    case "True":
                        info.Arguments = "-w -sndbkg";
                        break;

                    case "False":
                        info.Arguments = "-w -ns";
                        break;
                    }

                    ConsoleTab.WriteLine("Loading " + exePath);

                    diabloProcess = Process.Start(info);
                    diabloProcess.EnableRaisingEvents = true;
                    diabloProcess.Exited += new EventHandler(diabloProcess_Exited);

                    // Wait for the app to load
                    diabloProcess.WaitForInputIdle();

                    diabloHandle = diabloProcess.MainWindowHandle;

                    // If greater than Windows XP
                    if (System.Environment.OSVersion.Version.Major > 5)
                    {
                        diabloWindow = new DiabloWindow(Application.OpenForms[0], diabloPanel, diabloHandle, this.Text);
                        diabloPanel.BindDiabloWindow(diabloWindow);

                        if (((TabControl)this.Parent).SelectedTab == this)
                        {
                            diabloWindow.Activate();
                        }
                        else
                        {
                            diabloWindow.Deactivate();
                        }
                    }
                    if (BlueVex2.Properties.Settings.Default.UseBV2AutoLogin)
                    {
                        ((IDiabloWindow)diabloWindow).LoginToBattleNet(this.defaultAccount);
                    }
                }
                else
                {
                    ConsoleTab.WriteLine("Could not find diablo 2 game.exe " + exePath);
                }
            }
        }