public void ShowMe(MainForm parent, int addEdit, Account account = null) { if (addEdit == 0) { this.Text = "New Account"; } else { this.Text = "Edit Account"; } this.account = account; this.addEdit = addEdit; mForm = parent; this.ShowDialog(parent); }
public void SetAccount(Account account) { this.account = account; }
private void SetWTFAndStart(Process process, Account account) { // Get options for account options.SetAccount(account); // Find or create directory if (!Directory.Exists(SETTINGS.WowPath + @"\WTF")) { Directory.CreateDirectory(SETTINGS.WowPath + @"\WTF"); } else { if (File.Exists(SETTINGS.WowPath + @"\WTF\Config.wtf")) { // Modify current config file File.WriteAllLines(SETTINGS.WowPath + @"\WTF\Config.wtf", File.ReadLines(SETTINGS.WowPath + @"\WTF\Config.wtf"). Where(line => !line.Contains("readTOS")). Where(line => !line.Contains("readEULA")). Where(line => !line.Contains("accountName")). Where(line => !line.Contains("gxWindow")). Where(line => !line.Contains("hwDetect")). Where(line => !line.Contains("gxMaximize")). Where(line => !line.Contains("accountList")). Where(line => !line.Contains("graphicsQuality")). Where(line => !line.Contains(account.SetRealm ? "realmName" : "null")). Where(line => !line.Contains(account.Windowed ? "gxResolution" : "null")). Where(line => !line.Contains(account.LowDetail ? "gxApi" : "null")). Where(line => !line.Contains(account.SetCharacter ? "lastCharacterIndex" : "null")). ToList()); File.AppendAllLines(SETTINGS.WowPath + @"\WTF\Config.wtf", options.CompiledList()); } else { // Create new config file File.WriteAllLines(SETTINGS.WowPath + @"\WTF\Config.wtf", options.CompiledList()); } } // Sleep to give harddrive time to save file Thread.Sleep(250); process.Start(); // Sleep long enough for Wow to read file Thread.Sleep(400); }
private void lstAccounts_SelectedIndexChanged(object sender, EventArgs e) { if (lstAccounts.DataSource != null) { // Set active account when 1 account clicked if (lstAccounts.SelectedItems.Count == 1) { ActiveAccount = ACCOUNTS.Find(a => a.Name == lstAccounts.SelectedItem.ToString()); // Set the 32bit/64bit selection if (ActiveAccount.Client == "32bit") { rdo32bit.Checked = true; } else { rdo64bit.Checked = true; } } // If more than one account is selected disable the edit button and 32bit/64bit selection if (lstAccounts.SelectedItems.Count > 1) { rdo32bit.Enabled = false; rdo64bit.Enabled = false; btnEdit.Enabled = false; } else { rdo32bit.Enabled = true; rdo64bit.Enabled = true; btnEdit.Enabled = true; } } }
private void Login(Process p, Account a) { // Run this in a new thread so AutoLogin is not frozen new Thread(() => { try { // Run in background Thread.CurrentThread.IsBackground = true; // Set keycodes uint WM_KEYDOWN = 0x0100; uint WM_KEYUP = 0x0101; uint WM_CHAR = 0x0102; int VK_RETURN = 0x0D; // Set local account/password, otherwise it uses the account/password that changes each time Login() is called Process process = p; Account account = a; do // Keep repeating till window is idle { process.WaitForInputIdle(); process.Refresh(); } while (process.MainWindowHandle.ToInt32() == 0); // Sleep for a little to give the insides time to load Thread.Sleep(account.Windowed ? 600 : 1500); // Send the password one key at a time for (int i = 0; i < account.Password.Length; i++) { PostMessage(process.MainWindowHandle, WM_CHAR, new IntPtr(account.Password[i]), IntPtr.Zero); Thread.Sleep(30); } // Hit enter to log in PostMessage(process.MainWindowHandle, WM_KEYDOWN, new IntPtr(VK_RETURN), IntPtr.Zero); // Wait 15 seconds and press Enter if (account.EnterWorld) { Thread.Sleep(15000); PostMessage(process.MainWindowHandle, WM_KEYUP, new IntPtr(VK_RETURN), IntPtr.Zero); PostMessage(process.MainWindowHandle, WM_KEYDOWN, new IntPtr(VK_RETURN), IntPtr.Zero); } Thread.CurrentThread.Abort(); } catch { // Crash probably due to process closing Thread.CurrentThread.Abort(); } }).Start(); }
private void btnRemove_Click(object sender, EventArgs e) { if (ActiveAccount != null) { if (lstAccounts.SelectedItems.Count == 1) { if (MessageBox.Show("Remove this account?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) { ACCOUNTS.Remove(ActiveAccount); } } else if (lstAccounts.SelectedItems.Count > 0) { if (MessageBox.Show("Remove these accounts?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) { for (int i = 0; i < lstAccounts.SelectedItems.Count; i++) { ACCOUNTS.Remove(ACCOUNTS.Find(a => a.Name == lstAccounts.SelectedItems[i].ToString())); } } } ActiveAccount = null; refreshList(); } }
private void btnSave_Click(object sender, EventArgs e) { try { // If this fails the email is not valid new MailAddress(txtEmail.Text); // Check if password is entered if (txtPassword.Text == "") { MessageBox.Show("Password required!"); } else { // If no name set use email address if (txtName.Text == "") { txtName.Text = txtEmail.Text; } // If "adding" create a new account if (account == null) { account = new Account(); account.Client = "32bit"; MainForm.ACCOUNTS.Add(account); } // Save all account information to account object account.Name = txtName.Text; account.Email = txtEmail.Text; account.Password = txtPassword.Text; account.Multiple = chkMultiple.Checked; account.NumberAccounts = chkMultiple.Checked ? (int)numAccounts.Value : 0; account.AccountNames = new string[lstAccounts.Items.Count]; lstAccounts.Items.CopyTo(account.AccountNames, 0); account.SelectedAccount = chkMultiple.Checked ? lstAccounts.SelectedIndices[0] : 0; account.Windowed = chkWindowed.Checked; account.Resolution = drpResolution.Text; account.LowDetail = chkLowDetail.Checked; account.SetRealm = chkRealm.Checked; account.Realm = drpRealm.Text; account.SetCharacter = chkCharacter.Checked; account.CharacterSlot = lstCharacter.SelectedIndex; account.EnterWorld = chkEnterWorld.Checked; mForm.refreshList(addEdit); this.Close(); } } catch (Exception) { MessageBox.Show("Valid email address required!"); } }