// The get OTP button. private void getOtpButton_Click(object sender, EventArgs e) { if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } if (listView1.SelectedItems.Count <= 0 || this.loginWorker.IsBusy) { return; } if (Properties.Settings.Default.autoSelect == true) { Properties.Settings.Default.autoSelectIndex = listView1.SelectedItems[0].Index; Properties.Settings.Default.Save(); } this.textBox3.Text = "獲取密碼中..."; this.listView1.Enabled = false; this.getOtpButton.Enabled = false; this.comboBox2.Enabled = false; if (Properties.Settings.Default.GAEnabled) { timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("GetOTP", Properties.Settings.Default.loginMethod.ToString()); AutoMeasurement.Client.TrackEvent("GetOTP" + Properties.Settings.Default.loginMethod.ToString(), "GetOTP"); } this.getOtpWorker.RunWorkerAsync(listView1.SelectedItems[0].Index); }
public MainWindow() { if (Properties.Settings.Default.GAEnabled) { try { AutoMeasurement.Instance = new WinFormAutoMeasurement(); AutoMeasurement.DebugWriter = d => Debug.WriteLine(d); AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion.ToString())); } catch { this.timedActivity = null; Properties.Settings.Default.GAEnabled = false; Properties.Settings.Default.Save(); } } //TODO:注意关闭时登出 /* this.FormClosing += new FormClosingEventHandler((sender, e) => { * if (this.bfClient != null) this.bfClient.Logout(); * });*/ timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString()); InitializeComponent(); init(); if (Properties.Settings.Default.GAEnabled && this.timedActivity != null) { AutoMeasurement.Client.Track(this.timedActivity); this.timedActivity = null; } }
public main() { currentVersion = currentVersion.Remove(currentVersion.Length - 2); if (Properties.Settings.Default.GAEnabled) { try { AutoMeasurement.Instance = new WinFormAutoMeasurement(); AutoMeasurement.DebugWriter = d => Debug.WriteLine(d); AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion)); } catch { this.timedActivity = null; Properties.Settings.Default.GAEnabled = false; Properties.Settings.Default.Save(); } } timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString()); InitializeComponent(); init(); CheckForUpdate(); if (Properties.Settings.Default.GAEnabled && this.timedActivity != null) { AutoMeasurement.Client.Track(this.timedActivity); this.timedActivity = null; } }
private void btn_getOpt_Click(object sender, RoutedEventArgs e) { if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } if (lv_opt_account.SelectedItems.Count <= 0 || this.loginWorker.IsBusy) { return; } if (Properties.Settings.Default.autoSelect == true) { Properties.Settings.Default.autoSelectIndex = lv_opt_account.SelectedIndex; Properties.Settings.Default.Save(); } this.tb_opt_pwd.Text = "獲取密碼中..."; this.lv_opt_account.IsEnabled = false; this.btn_getOpt.IsEnabled = false; /* this.comboBox2.Enabled = false;*/ if (Properties.Settings.Default.GAEnabled) { timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("GetOTP", Properties.Settings.Default.loginMethod.ToString()); AutoMeasurement.Client.TrackEvent("GetOTP" + Properties.Settings.Default.loginMethod.ToString(), "GetOTP"); } this.getOtpWorker.RunWorkerAsync(lv_opt_account.SelectedIndex); }
// The login botton. private void loginButton_Click(object sender, EventArgs e) { foreach (ListViewItem item in listView1.Items) { item.BackColor = DefaultBackColor; } if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } if (this.rememberAccount.Checked == true) { Properties.Settings.Default.AccountID = this.accountInput.Text; } if (this.rememberAccPwd.Checked == true) { using (BinaryWriter writer = new BinaryWriter(File.Open("UserState.dat", FileMode.Create))) { // Create random entropy of 8 characters. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var random = new Random(); string entropy = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray()); Properties.Settings.Default.entropy = entropy; writer.Write(ciphertext(this.passwdInput.Text, entropy)); } } else { Properties.Settings.Default.entropy = ""; File.Delete("UserState.dat"); } Properties.Settings.Default.Save(); this.UseWaitCursor = true; this.panel2.Enabled = false; this.loginButton.Text = "請稍後..."; if (Properties.Settings.Default.GAEnabled) { timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("Login", Properties.Settings.Default.loginMethod.ToString()); AutoMeasurement.Client.TrackEvent("Login" + Properties.Settings.Default.loginMethod.ToString(), "Login"); } this.loginWorker.RunWorkerAsync(Properties.Settings.Default.loginMethod); }
private void btn_login_Click(object sender, RoutedEventArgs e) { if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } /* if (this.rememberAccount.Checked == true) * Properties.Settings.Default.AccountID = this.accountInput.Text; * if (this.rememberAccPwd.Checked == true) * { * using (BinaryWriter writer = new BinaryWriter(File.Open("UserState.dat", FileMode.Create))) * { * // Create random entropy of 8 characters. * var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; * var random = new Random(); * string entropy = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray()); * * Properties.Settings.Default.entropy = entropy; * writer.Write(ciphertext(this.passwdInput.Text, entropy)); * } * } * else * { * Properties.Settings.Default.entropy = ""; * File.Delete("UserState.dat"); * }*/ Properties.Settings.Default.Save(); /* * this.UseWaitCursor = true; */ this.btn_login.Content = "請稍後..."; if (Properties.Settings.Default.GAEnabled) { timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("Login", Properties.Settings.Default.loginMethod.ToString()); AutoMeasurement.Client.TrackEvent("Login" + Properties.Settings.Default.loginMethod.ToString(), "Login"); } this.loginWorker.RunWorkerAsync(Properties.Settings.Default.loginMethod); }
public main() { currentVersion = currentVersion.Remove(currentVersion.Length - 2); if (Properties.Settings.Default.GAEnabled) { try { AutoMeasurement.Instance = new WinFormAutoMeasurement(); AutoMeasurement.DebugWriter = d => Debug.WriteLine(d); AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion)); } catch { this.timedActivity = null; Properties.Settings.Default.GAEnabled = false; Properties.Settings.Default.Save(); } } timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString()); InitializeComponent(); init(); CheckForUpdate(); //string[] lines = System.IO.File.ReadAllLines(@"C:\POP\12.txt"); //string[] lines = System.IO.File.ReadAllLines(@"\\vmware-host\Shared Folders\POP\2.txt"); //string[] words = lines[0].Split((char)9); //this.accountInput.Text = words[0]; //this.passwdInput.Text = words[1]; this.accountInput.Text = "alanting0004"; this.passwdInput.Text = "sf7778101"; /*if (words[0] == "" || words[1] == "") * { * this.loginButton.Enabled = true; * } * else {*/ this.loginButton.Enabled = false; this.loginWorker.RunWorkerAsync(0); //} }
// Login completed. private void loginWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (Properties.Settings.Default.GAEnabled && this.timedActivity != null) { AutoMeasurement.Client.Track(this.timedActivity); this.timedActivity = null; } if (Properties.Settings.Default.keepLogged && !this.pingWorker.IsBusy) { this.pingWorker.RunWorkerAsync(); } Debug.WriteLine("loginWorker end"); this.panel2.Enabled = true; this.UseWaitCursor = false; this.loginButton.Text = "登入"; if (e.Error != null) { errexit(e.Error.Message, 1); return; } if ((string)e.Result != null) { errexit((string)e.Result, 1); return; } try { listView1.Items.Clear(); foreach (var account in this.bfClient.accountList) { string[] row = { WebUtility.HtmlDecode(account.sname), account.sacc }; var listViewItem = new ListViewItem(row); this.listView1.Items.Add(listViewItem); } // Handle panel switching. this.ActiveControl = null; this.Size = new System.Drawing.Size(300, 290); this.panel2.SendToBack(); this.panel1.BringToFront(); this.AcceptButton = this.getOtpButton; if (Properties.Settings.Default.autoSelectIndex < this.listView1.Items.Count) { this.listView1.Items[Properties.Settings.Default.autoSelectIndex].Selected = true; } this.listView1.Select(); if (Properties.Settings.Default.autoSelect == true && Properties.Settings.Default.autoSelectIndex < this.bfClient.accountList.Count()) { if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } this.textBox3.Text = "獲取密碼中..."; this.listView1.Enabled = false; this.getOtpButton.Enabled = false; timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("GetOTP", Properties.Settings.Default.loginMethod.ToString()); if (Properties.Settings.Default.GAEnabled) { AutoMeasurement.Client.TrackEvent("GetOTP" + Properties.Settings.Default.loginMethod.ToString(), "GetOTP"); } this.getOtpWorker.RunWorkerAsync(Properties.Settings.Default.autoSelectIndex); } if (Properties.Settings.Default.keepLogged && !this.pingWorker.IsBusy) { this.pingWorker.RunWorkerAsync(); } ShowToolTip(listView1, "步驟1", "選擇欲開啟的遊戲帳號,雙擊以複製帳號。"); ShowToolTip(getOtpButton, "步驟2", "按下以在右側產生並自動複製密碼,至遊戲中貼上帳密登入。"); Tip.SetToolTip(getOtpButton, "點擊獲取密碼"); Tip.SetToolTip(listView1, "雙擊即自動複製"); Tip.SetToolTip(textBox3, "點擊一次即自動複製"); Properties.Settings.Default.showTip = false; Properties.Settings.Default.Save(); } catch { errexit("登入失敗,無法取得帳號列表。", 1); } }
// getOTP completed. private void getOtpWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (Properties.Settings.Default.GAEnabled && this.timedActivity != null) { AutoMeasurement.Client.Track(this.timedActivity); this.timedActivity = null; } const int VK_TAB = 0x09; const byte VK_CONTROL = 0x11; const int VK_V = 0x56; const int VK_ENTER = 0x0d; const byte KEYEVENTF_EXTENDEDKEY = 0x1; const byte KEYEVENTF_KEYUP = 0x2; Debug.WriteLine("getOtpWorker end"); this.btn_getOpt.Content = "獲取密碼"; this.lv_opt_account.IsEnabled = true; this.btn_getOpt.IsEnabled = true; if (e.Error != null) { this.tb_opt_pwd.Text = "獲取失敗"; errexit(e.Error.Message, 2); return; } int index = (int)e.Result; if (index == -1) { this.tb_opt_pwd.Text = "獲取失敗"; errexit(this.bfClient.errmsg, 2); } else { int accIndex = lv_opt_account.SelectedIndex; string acc = this.bfClient.accountList[index].sacc; try { Clipboard.SetText(acc); } catch { return; } IntPtr hWnd; /* if (autoPaste.Checked == true && (hWnd = WindowsAPI.FindWindow(null, "MapleStory")) != IntPtr.Zero) * { * WindowsAPI.SetForegroundWindow(hWnd); * * WindowsAPI.keybd_event(VK_CONTROL, 0x9d, KEYEVENTF_EXTENDEDKEY, 0); * WindowsAPI.keybd_event(VK_V, 0x9e, 0, 0); * Thread.Sleep(200); * WindowsAPI.keybd_event(VK_V, 0x9e, KEYEVENTF_KEYUP, 0); * Thread.Sleep(200); * WindowsAPI.keybd_event(VK_CONTROL, 0x9d, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); * * WindowsAPI.keybd_event(VK_TAB, 0, KEYEVENTF_EXTENDEDKEY, 0); * WindowsAPI.keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0); * }*/ this.tb_opt_pwd.Text = this.otp.Substring(0, 10); try { Clipboard.SetText(tb_opt_pwd.Text); } catch { return; } Thread.Sleep(250); /* if (autoPaste.Checked == true && (hWnd = WindowsAPI.FindWindow(null, "MapleStory")) != IntPtr.Zero) * { * WindowsAPI.keybd_event(VK_CONTROL, 0x9d, KEYEVENTF_EXTENDEDKEY, 0); * WindowsAPI.keybd_event(VK_V, 0x9e, 0, 0); * Thread.Sleep(200); * WindowsAPI.keybd_event(VK_V, 0x9e, KEYEVENTF_KEYUP, 0); * Thread.Sleep(200); * WindowsAPI.keybd_event(VK_CONTROL, 0x9d, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); * * WindowsAPI.keybd_event(VK_ENTER, 0, 0, 0); * WindowsAPI.keybd_event(VK_ENTER, 0, KEYEVENTF_KEYUP, 0); * * listView1.Items[accIndex].BackColor = Color.Green; * listView1.Items[accIndex].Selected = false; * }*/ } if (Properties.Settings.Default.keepLogged && !this.pingWorker.IsBusy) { this.pingWorker.RunWorkerAsync(); } }
// Login completed. private void loginWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (Properties.Settings.Default.GAEnabled && this.timedActivity != null) { AutoMeasurement.Client.Track(this.timedActivity); this.timedActivity = null; } if (Properties.Settings.Default.keepLogged && !this.pingWorker.IsBusy) { this.pingWorker.RunWorkerAsync(); } Debug.WriteLine("loginWorker end"); /* this.panel2.Enabled = true; * this.UseWaitCursor = false; * this.loginButton.Text = "登入";*/ grid_login.Visibility = Visibility.Collapsed; if (e.Error != null) { errexit(e.Error.Message, 1); return; } if ((string)e.Result != null) { errexit((string)e.Result, 1); return; } try { redrawSAccountList(); // Handle panel switching. /* this.ActiveControl = null;*/ /* this.Size = new System.Drawing.Size(300, this.Size.Height); * this.panel2.SendToBack(); * this.panel1.BringToFront();*/ /* this.AcceptButton = this.btn_getOpt;*/ //如果账号列表UI够长,就选择默认选中的那个索引 if (Properties.Settings.Default.autoSelectIndex < this.lv_opt_account.Items.Count) { this.lv_opt_account.SelectedIndex = Properties.Settings.Default.autoSelectIndex; } /* this.lv_opt_account.Select();*/ if (Properties.Settings.Default.autoSelect == true && Properties.Settings.Default.autoSelectIndex < this.bfClient.accountList.Count()) { if (this.pingWorker.IsBusy) { this.pingWorker.CancelAsync(); } this.tb_opt_pwd.Text = "獲取密碼中..."; this.lv_opt_account.IsEnabled = false; this.btn_getOpt.IsEnabled = false; timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("GetOTP", Properties.Settings.Default.loginMethod.ToString()); if (Properties.Settings.Default.GAEnabled) { AutoMeasurement.Client.TrackEvent("GetOTP" + Properties.Settings.Default.loginMethod.ToString(), "GetOTP"); } this.getOtpWorker.RunWorkerAsync(Properties.Settings.Default.autoSelectIndex); } if (Properties.Settings.Default.keepLogged && !this.pingWorker.IsBusy) { this.pingWorker.RunWorkerAsync(); } /* ShowToolTip(listView1, "步驟1", "選擇欲開啟的遊戲帳號,雙擊以複製帳號。"); * ShowToolTip(getOtpButton, "步驟2", "按下以在右側產生並自動複製密碼,至遊戲中貼上帳密登入。"); * Tip.SetToolTip(getOtpButton, "點擊獲取密碼"); * Tip.SetToolTip(listView1, "雙擊即自動複製"); * Tip.SetToolTip(textBox3, "點擊一次即自動複製");*/ Properties.Settings.Default.showTip = false; Properties.Settings.Default.Save(); } catch { errexit("登入失敗,無法取得帳號列表。", 1); } }