Пример #1
0
        public bool StartSteamAccount(SteamAccount acc)
        {
            bool finished = false;

            if (IsSteamRunning())
            {
                CleanKillSteam();
            }

            int waitTimer = 30;

            while (finished == false)
            {
                if (waitTimer == 0)
                {
                    KillSteam();
                    Debug.WriteLine("Hard killed steam.");
                }
                if (IsSteamRunning() == false)
                {
                    Process p = new Process();
                    if (File.Exists(installDir))
                    {
                        p.StartInfo = new ProcessStartInfo(installDir, acc.getStartParameters());
                        p.Start();
                        finished = true;

                        return(true);
                    }
                }
                Thread.Sleep(100);
                waitTimer--;
            }
            return(false);
        }
 private void steamAccount_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount >= 2)
     {
         SteamAccount selectedAcc = (SteamAccount)listBoxAccounts.SelectedItem;
         SasManager.Instance.StartSteamWithAccount(selectedAcc);
     }
 }
        /// <summary>
        /// Uses the technique from TcNo Account Switcher to change the loginUsers.vdf and
        /// some registry values so on next start steam is starting with the defined user
        /// only works if the user already logged in once with this account and chose "remember password"!
        /// </summary>
        /// <param name="selectedAccount">the account to start with</param>
        public void startCachedAccount(SteamAccount selectedAccount)
        {
            _steamInstallation.KillSteam();
            dynamic loginUsersVdf = VdfConvert.Deserialize(File.ReadAllText(loginUsersVDFPath));

            try
            {
                foreach (var account in loginUsersVdf.Value)
                {
                    if (account.Key.ToString() == selectedAccount.SteamId)
                    {
                        account.Value.MostRecent.Value = "1";
                        if (account.Value.RememberPassword.Value == "0")
                        {
                            // Steam does not remember this accounts password!
                            if (!string.IsNullOrEmpty(selectedAccount.Password))
                            {
                                // If the user has a password, we use that to log in the old way
                                resetActiveAccount();
                                _steamInstallation.StartSteamAccount(selectedAccount);
                            }
                            else
                            {
                                // Else we notify the user and let him log in
                                MessageBox.Show(
                                    "This account does not have a password associated with it and can only be started if it has already logged in once and 'Remember Password' has been checked. Log in and select 'Remember Password' now or add a password in SteamAccountSwitcher.",
                                    "Cannot start with account", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                break;
                            }
                        }
                    }
                    else
                    {
                        account.Value.MostRecent.Value = "0";
                    }
                }

                //MessageBox.Show(loginUsersVdf.ToString());
                File.WriteAllText(loginUsersVDFPath, loginUsersVdf.ToString());

                using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Valve\Steam"))
                {
                    key.SetValue("AutoLoginUser", selectedAccount.AccountName);
                    key.SetValue("RememberPassword", 1);
                }
                _steamInstallation.Start();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #4
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateInput())
            {
                newAcc          = new SteamAccount();
                newAcc.Type     = (AccountType)comboBoxType.SelectedValue;
                newAcc.Name     = textBoxName.Text;
                newAcc.Username = textBoxUsername.Text;
                newAcc.Password = textBoxPassword.Password;

                Close();
            }
        }
        private void AskForDeletionOfAccount(SteamAccount selectedAccount)
        {
            var result = MessageBox.Show(
                "Are you sure you want to delete the account profile of " + selectedAccount.ToString() + "?",
                "Deletion prompt",
                MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (result == MessageBoxResult.Yes)
            {
                SasManager.Instance.AccountList.Remove(selectedAccount);
                buttonEdit.IsEnabled = false; // Cannot edit deleted account
                listBoxAccounts.Items.Refresh();
            }
        }
        //ObservableCollection<SteamAccount> accountList = new ObservableCollection<SteamAccount>();

        public MainWindow()
        {
            AutoUpdater.Start("https://wedenig.org/SteamAccountSwitcher/version.xml");

            InitializeComponent();

            //Restore size
            this.Top    = Properties.Settings.Default.Top;
            this.Left   = Properties.Settings.Default.Left;
            this.Height = Properties.Settings.Default.Height;
            this.Width  = Properties.Settings.Default.Width;

            if (Properties.Settings.Default.Maximized)
            {
                WindowState = WindowState.Maximized;
            }

            fixOutOfBoundsWindow();

            askUserForSteamLocation();

            showSteamStatus();


            try
            {
                SasManager.Instance.InitializeAccountsFromFile();
            }
            catch
            {
                MessageBox.Show(
                    "Account file is currupted or wrong encryption method is set. Check Settings and try again. Save on close has been disabled so that nothing can be overwritten! Make sure to restart the applications after switching EncryptionType method!",
                    "Error parsing file", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }


            SteamAccount sa = new SteamAccount("username", "testpw");

            sa.Name = "profile name";
            //accountList.Add(sa);

            listBoxAccounts.ItemsSource = SasManager.Instance.AccountList;
            listBoxAccounts.Items.Refresh();

            Style itemContainerStyle = new Style(typeof(ListBoxItem));

            //take full width
            itemContainerStyle.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
            listBoxAccounts.ItemContainerStyle = itemContainerStyle;
        }
Пример #7
0
        /// <summary>
        /// Creates a new instance of the AccountWindow class. Allows the user to edit new accounts
        /// </summary>
        /// <param name="accToEdit">The account to edit.</param>
        public AccountWindow(SteamAccount accToEdit)
        {
            if (accToEdit == null)
            {
                throw new ArgumentNullException();
            }

            InitializeComponent();
            this.Title = "Edit Account";

            comboBoxType.ItemsSource  = Enum.GetValues(typeof(AccountType));
            comboBoxType.SelectedItem = accToEdit.Type;

            textBoxName.Text         = accToEdit.Name;
            textBoxUsername.Text     = accToEdit.Username;
            textBoxPassword.Password = accToEdit.Password;
        }
 private void listBoxAccounts_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         SteamAccount selectedAcc = (SteamAccount)listBoxAccounts.SelectedItem;
         if (Properties.Settings.Default.safemode)
         {
             steam.StartSteamAccountSafe(selectedAcc);
             Mouse.OverrideCursor = Cursors.Wait;
         }
         else
         {
             steam.StartSteamAccount(selectedAcc);
         }
     }
     finally
     {
         Mouse.OverrideCursor = null;
     }
 }
        /// <summary>
        /// Creates a new instance of the AccountWindow class. Allows the user to edit new accounts
        /// </summary>
        /// <param name="accToEdit">The account to edit.</param>
        public AccountWindow(SteamAccount accToEdit)
        {
            if (accToEdit == null)
            {
                throw new ArgumentNullException();
            }

            InitializeComponent();
            this.Title = "Edit Account";
            newAcc     = accToEdit;

            comboBoxType.ItemsSource  = Enum.GetValues(typeof(AccountType));
            comboBoxType.SelectedItem = accToEdit.Type;

            textBoxName.Text         = accToEdit.Name;
            textBoxUsername.Text     = accToEdit.AccountName;
            textBoxPassword.Password = accToEdit.Password;

            textBoxUsername.IsEnabled = accToEdit.CachedAccount;
            labelIsCached.Visibility  = accToEdit.CachedAccount ? Visibility.Visible : Visibility.Collapsed;
        }
Пример #10
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateInput())
            {
                if (Account == null)
                {
                    Account = new SteamAccount(textBoxUsername.Text, textBoxPassword.Password)
                    {
                        Type = (AccountType)comboBoxType.SelectedValue,
                        Name = textBoxName.Text
                    };
                }
                else
                {
                    Account.AccountName = textBoxUsername.Text;
                    Account.Password    = textBoxPassword.Password;
                    Account.Name        = textBoxName.Text;
                    Account.Type        = (AccountType)comboBoxType.SelectedValue;
                }


                Close();
            }
        }
        public MainWindow()
        {
            AutoUpdater.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); //Workaround for horrible AutoUpdater translations :D
            AutoUpdater.Start("http://wedenig.org/SteamAccountSwitcher/version.xml");

            InitializeComponent();
            //statusBarLabel.Content = AppDomain.CurrentDomain.BaseDirectory; //Debug location

            //Restore size
            this.Top    = Properties.Settings.Default.Top;
            this.Left   = Properties.Settings.Default.Left;
            this.Height = Properties.Settings.Default.Height;
            this.Width  = Properties.Settings.Default.Width;

            if (Properties.Settings.Default.Maximized)
            {
                WindowState = WindowState.Maximized;
            }

            fixOutOfBoundsWindow();

            //No steam directory in Settings, let's find 'em!
            if (Properties.Settings.Default.steamInstallDir == String.Empty)
            {
                //Run this on first start
                string installDir = UserInteraction.selectSteamDirectory(@"C:\Program Files (x86)\Steam");
                if (installDir == null)
                {
                    MessageBox.Show("You cannot use SteamAccountSwitcher without selecting your Steam.exe. Program will close now.", "Steam missing", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
                else
                {
                    Properties.Settings.Default.steamInstallDir = installDir;
                    steam = new Steam(installDir);
                }
            }
            else
            {
                //Start steam from existing installation path
                steam = new Steam(Properties.Settings.Default.steamInstallDir);
            }

            //statusBarLabel.Content = "Steam running in '" + Properties.Settings.Default.steamInstallDir + "'";
            statusBarLabel.Content = SteamStatus.steamStatusMessage();
            statusbar.Background   = SteamStatus.getStatusColor();

            loader = new AccountLoader(Encryption.Basic);

            //accountList = new ObservableCollection<SteamAccount>(loader.LoadBasicAccounts());
            if (loader.AccountFileExists())
            {
                //Try to get accounts
                try
                {
                    accountList = new ObservableCollection <SteamAccount>(loader.LoadBasicAccounts());
                }
                catch
                {
                    MessageBox.Show("Account file is currupted or wrong encryption method is set. Check Settings and try again. AutoSave has been disabled so that nothing can be overwritten! Make sure to restart the applications after switching Encryption method!", "Error parsing file", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    accountList      = new ObservableCollection <SteamAccount>();
                    autosaveAccounts = false;
                }
            }
            else
            {
                accountList = new ObservableCollection <SteamAccount>();
            }

            SteamAccount sa = new SteamAccount("username", "testpw");

            sa.Name = "profile name";
            //accountList.Add(sa);

            listBoxAccounts.ItemsSource = accountList;
            listBoxAccounts.Items.Refresh();

            Style itemContainerStyle = new Style(typeof(ListBoxItem));

            //take full width
            itemContainerStyle.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
            listBoxAccounts.ItemContainerStyle = itemContainerStyle;
        }
Пример #12
0
        public bool StartSteamAccountSafe(SteamAccount acc)
        {
            Process p;
            bool    finished    = false;
            string  loginString = "-login " + acc.Username + " SAS-SAFEMODE";

            p           = new Process();
            p.StartInfo = new ProcessStartInfo(installDir, "-fs_log " + loginString);

            if (IsSteamRunning())
            {
                CleanKillSteam();
            }

            int waitTimer = 30;

            while (finished == false)
            {
                Debug.WriteLine("Waiting for steam to exit...");
                if (waitTimer == 0)
                {
                    KillSteam();
                    Debug.WriteLine("Hard killed steam.");
                }

                if (IsSteamRunning() == false)
                {
                    p.Start();
                    finished = true;

                    System.Threading.Thread.Sleep(5000);
                    bool steamNotUpdating = false;
                    while (steamNotUpdating == false)
                    {
                        steamNotUpdating = IsSteamReady();
                    }

                    if (steamNotUpdating)
                    {
                        try
                        {
                            Debug.WriteLine("Starting input manager!");
                            System.Threading.Thread.Sleep(1500);
                            Debug.WriteLine("Done waiting.");

                            IntPtr handle = p.MainWindowHandle;
                            if (IsIconic(handle))
                            {
                                ShowWindow(handle, SW_RESTORE);
                            }
                            //SetForegroundWindow(handle);
                            //Clipboard.SetText(acc.Username);
                            InputSimulator s = new InputSimulator();
                            //s.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);

                            Debug.WriteLine("Focused window");
                            //s.Keyboard.TextEntry(acc.Username);
                            //System.Threading.Thread.Sleep(100);
                            //s.Keyboard.KeyDown(VirtualKeyCode.TAB);
                            //s.Keyboard.KeyUp(VirtualKeyCode.TAB);
                            //System.Threading.Thread.Sleep(100);
                            System.Threading.Thread.Sleep(500);
                            Debug.WriteLine("ENTERING PW NOW");
                            s.Keyboard.TextEntry(acc.Password);
                            System.Threading.Thread.Sleep(100);
                            s.Keyboard.KeyDown(VirtualKeyCode.RETURN);

                            return(true);
                        }
                        catch
                        {
                            MessageBox.Show("Error logging in. Steam not in foreground.");
                        }
                        //MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                    }
                    Thread.Sleep(100);
                    waitTimer--;
                }
            }
            return(false);
        }
Пример #13
0
 private void buttonCancel_Click(object sender, RoutedEventArgs e)
 {
     newAcc = null;
     Close();
 }