public static void ClickSoloDuoRanked() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.RankedSoloDuoCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Summoner Mode: Ranked Pick X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); }
public static void ClickAcceptButton() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.AutoAcceptButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Auto Accept: Clicked Accept Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); }
public static void ClickARAMMatch() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.ARAMMatchCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Pick ARAM Mode X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); }
private async void AcceptMatchButton() { bool championSearchbox = false; bool accepted = false; while (!championSearchbox) { TakeFullDesktopScreenShot(); if (!championSearchbox) { championSearchbox = await ImageRecognition.AutoFindChampionSearchTextboxImageRecognition(); } TakeFullDesktopScreenShot(); if (!accepted) { accepted = await ImageRecognition.AutoAcceptImageRecognition(); } if (accepted) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.AutoAcceptButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Auto Accept: Clicked Accept Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); SetLiveStatusText("Accepted Match", Color.Green); } } }
public static void ClickChamptionSearchTextbox() { int[] coordinatesChampionSearchTextbox = HelpFile.GetXYCoordinatesRegex(Options.ChampionSearchTextboxCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinatesChampionSearchTextbox[0], coordinatesChampionSearchTextbox[1]); HelpFile.Log("Select Champ: Search Text Box Clicked X:" + coordinatesChampionSearchTextbox[0] + ", Y:" + coordinatesChampionSearchTextbox[1] + "."); Thread.Sleep(Options.InteractionInterval); }
public static void ClickFirstChamptionBox() { int[] coordinatesFirstChampionBox = HelpFile.GetXYCoordinatesRegex(Options.FirstChampionBoxCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinatesFirstChampionBox[0], coordinatesFirstChampionBox[1]); HelpFile.Log("Select Champ: Moved Mouse To First Champion In List And Clicked X:" + coordinatesFirstChampionBox[0] + ", Y:" + coordinatesFirstChampionBox[1] + "."); Thread.Sleep(Options.InteractionInterval); }
public static async Task <bool> LoginPasswordImageRecognition() { Image <Bgr, byte> source = new Image <Bgr, byte>(new Bitmap(desktopScreenshot)); Image <Bgr, byte> template = new Image <Bgr, byte>(Resources.LeaguePassword); using (Image <Gray, float> result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) { double[] minValues, maxValues; Point[] minLocations, maxLocations; result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); if (maxValues[0] > 0.9) { Rectangle match = new Rectangle(maxLocations[0], template.Size); int X = match.X + (match.Width / 2); int Y = match.Y + (match.Height / 2); Options.LoginPasswordCoordinates = "X:" + X + "Y:" + Y; HelpFile.Log("Login Password: Returning True."); return(true); } else { return(false); } } }
public static void ClickSummonersMatch() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.SummonersRiftCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Pick Summoner Mode: Picked Summoner Rift X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); HelpFile.CreateLeagueFolder(); HelpFile.CheckIfFirstTime(); Application.Run(new LeagueAIO()); }
public static void PasteChampionName() { KeyboardEvents.SetClipboardText(Options.ChampionName); HelpFile.Log("Select Champ: Copied Champion Name To Clipboard."); Thread.Sleep(Options.InteractionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Select Champ: Pressed Control+V To Paste Champion Name."); Thread.Sleep(Options.InteractionInterval); }
private void LeagueAIO_FormClosing(object sender, FormClosingEventArgs e) { CancelAutoLogin = true; CancelAutoAcceptMatch = true; CancelAutoCreateMatch = true; CancelAutoSelectChampion = true; CancelAutoLockChampion = true; SaveOptions(); HelpFile.EndAppLog(); HelpFile.WriteLogToText(); }
private void SaveOptions() { Options.SummonerName = SummonerNameTextbox.Text; Options.Username = UsernameTextbox.Text; if (EncryptPasswordToggle.Checked) { if (Encryption.IsBase64String(PasswordTextbox.Text)) { Options.Password = PasswordTextbox.Text; } else { Options.Password = Encryption.ConvertToBase64(PasswordTextbox.Text); } } else { Options.Password = PasswordTextbox.Text; } Options.IsPasswordEncrypted = EncryptPasswordToggle.Checked; Options.LeagueExeDirectory = LeagueDirectoryTextbox.Text; Options.MatchType = MatchTypeCombobox.Text; Options.SummonerType = SummonerTypeCombobox.Text; Options.ChampionName = ChampionNameTextbox.Text; if (HelpFile.IsTextNumeric(InteractionIntervalTextbox.Text)) { Options.InteractionInterval = int.Parse(InteractionIntervalTextbox.Text); } Options.LoginUsernameCoordinates = CoordinatesLoginUsernameTextbox.Text; Options.LoginPasswordCoordinates = CoordinatesLoginPasswordTextbox.Text; Options.LoginButtonCoordinates = CoordinatesLoginButtonTextbox.Text; Options.PlayButtonCoordinates = CoordinatesPlayButtonTextbox.Text; Options.SummonersRiftCoordinates = CoordinatesSummonersMatchTextbox.Text; Options.ARAMMatchCoordinates = CoordinatesARAMMatchTextbox.Text; Options.BlindPickCoordinates = CoordinatesBlindPickTextbox.Text; Options.DraftPickCoordinates = CoordinatesDraftPickTextbox.Text; Options.RankedSoloDuoCoordinates = CoordinatesRankedSoloDuoTextbox.Text; Options.ConfirmButtonCoordinates = CoordinatesConfirmButtonTextbox.Text; Options.ChampionSearchTextboxCoordinates = CoordinatesChampionSearchTextbox.Text; Options.FirstChampionBoxCoordinates = CoordinatesFirstChampionBoxTextbox.Text; Options.LockButtonCoodinates = CoordinatesLockButtonTextbox.Text; Options.ContiuouslyMonitorAcceptMatch = ContiuouslyMonitorAcceptMatchCheckbox.Checked; Options.PrimaryColor = (Primary)Enum.Parse(typeof(Primary), PrimaryColourDropbox.SelectedItem.ToString()); Options.PrimaryDarkColor = (Primary)Enum.Parse(typeof(Primary), DarkPrimaryColourDropdownbox.SelectedItem.ToString()); Options.PrimaryLightColor = (Primary)Enum.Parse(typeof(Primary), LightPrimaryColourDropdownbox.SelectedItem.ToString()); Options.AccentColor = (Accent)Enum.Parse(typeof(Accent), AccentColourDropdownbox.SelectedItem.ToString()); Options.TextShadeColour = (TextShade)Enum.Parse(typeof(TextShade), TextshadeColourDropdownbox.SelectedItem.ToString()); }
private async void CreateARAMLobby() { bool clickedPlayButton = false; bool selectedARAM = false; bool clickedConfirmButton = false; while (!clickedConfirmButton) { TakeFullDesktopScreenShot(); if (!clickedPlayButton) { clickedPlayButton = await ImageRecognition.AutoClickPlayButtonImageRecognition(); } if (clickedPlayButton) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.PlayButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Click Play Button: Clicked Play Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } TakeFullDesktopScreenShot(); if (!selectedARAM) { selectedARAM = await ImageRecognition.AutoChooseARAMModeImageRecognition(); } if (selectedARAM) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.ARAMMatchCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Pick ARAM Mode X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } TakeFullDesktopScreenShot(); if (!clickedConfirmButton) { clickedConfirmButton = await ImageRecognition.AutoClickConfirmButtonImageRecognition(); } if (clickedConfirmButton) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.ConfirmButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Confirm Button: Clicked Confirm Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); AutoCreateSummonerRift = true; SetLiveStatusText("Created an ARAM room.", Color.Green); } } }
private void StartLeagueClient() { if (string.IsNullOrWhiteSpace(Options.LeagueExeDirectory)) { ShowMessageBox("League path directory is not selected! Please select league.exe", "Error 404: League.exe not found", MessageBoxIcon.Error); SetLiveStatusText("Error 404: League.exe not found. Please choose league.exe directory.", Color.Red); HelpFile.Log("Error 404: League.exe Not Found. Please Choose League.exe Directory."); AutoStartLeagueToggle.Checked = false; return; } Process.Start(Options.LeagueExeDirectory); SetLiveStatusText("Started the league client.", Color.Green); HelpFile.Log("League Client: Started The League.exe Client."); }
public static void EnterUsername() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LoginUsernameCoordinates); KeyboardEvents.SetClipboardText(Options.Username); HelpFile.Log("Login Username: Copied Username To Clipboard."); Thread.Sleep(Options.InteractionInterval); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Login Username: Moved Mouse To And Clicked Username Textbox X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Login Username: Pressed Control+V To Paste Username."); Thread.Sleep(Options.InteractionInterval); KeyboardEvents.ClearClipboard(); HelpFile.Log("Login Username: Cleared Clipboard Of Username."); Thread.Sleep(Options.InteractionInterval); }
public static void EnterPassword() { string password = Options.IsPasswordEncrypted ? Encryption.Decrypt(Options.Password, Encryption.ConvertRijndaelKeyToByteFromBase64(Options.EncryptedKey), Encryption.ConvertRijndaelIVToByteFromBase64(Options.EncryptedIV)) : Options.Password; int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LoginPasswordCoordinates); KeyboardEvents.SetClipboardText(password); HelpFile.Log("Login Password: Copied Text To Clipboard."); Thread.Sleep(Options.InteractionInterval); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Login Password: Moved Mouse To Textbox And Clicked X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.InteractionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Login Password: Pressed Control+V To Paste Password."); Thread.Sleep(Options.InteractionInterval); KeyboardEvents.ClearClipboard(); HelpFile.Log("Login Password: Cleared Clipboard Of Password."); Thread.Sleep(Options.InteractionInterval); }
public static async Task <bool> LoginFailedImageRecognition() { Image <Bgr, byte> source = new Image <Bgr, byte>(new Bitmap(desktopScreenshot)); Image <Bgr, byte> template = new Image <Bgr, byte>(Resources.LeagueLoginFailed); using (Image <Gray, float> result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) { double[] minValues, maxValues; Point[] minLocations, maxLocations; result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); if (maxValues[0] > 0.9) { HelpFile.Log("Login Has Failed. Returning True."); return(true); } else { return(false); } } }
private async void SelectChampion() { bool selectChampion = false; bool randomChampionBox = false; while (!selectChampion) { TakeFullDesktopScreenShot(); if (!randomChampionBox) { randomChampionBox = await ImageRecognition.AutoFindRandomChampionBoxImageRecognition(); } if (randomChampionBox) { KeyboardEvents.SetClipboardText(Options.ChampionName); HelpFile.Log("Select Champ: Copied Champion Name To Clipboard."); Thread.Sleep(Options.ImageRecognitionInterval); int[] coordinatesChampionSearchTextbox = HelpFile.GetXYCoordinatesRegex(Options.ChampionSearchTextboxCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinatesChampionSearchTextbox[0], coordinatesChampionSearchTextbox[1]); HelpFile.Log("Select Champ: Search Text Box Clicked X:" + coordinatesChampionSearchTextbox[0] + ", Y:" + coordinatesChampionSearchTextbox[1] + "."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Select Champ: Pressed Control+V To Paste Champion Name."); Thread.Sleep(Options.ImageRecognitionInterval); int[] coordinatesFirstChampionBox = HelpFile.GetXYCoordinatesRegex(Options.FirstChampionBoxCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinatesFirstChampionBox[0], coordinatesFirstChampionBox[1]); HelpFile.Log("Select Champ: Moved Mouse To First Champion In List And Clicked X:" + coordinatesFirstChampionBox[0] + ", Y:" + coordinatesFirstChampionBox[1] + "."); Thread.Sleep(Options.ImageRecognitionInterval); selectChampion = true; AutoSelectChampion = true; SetLiveStatusText(Options.ChampionName + " was selected.", Color.Green); } } }
private async void LockChampion() { bool lockChampion = false; while (!lockChampion) { TakeFullDesktopScreenShot(); if (!lockChampion) { lockChampion = await ImageRecognition.AutoLockChampionImageRecognition(); } if (lockChampion) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LockButtonCoodinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Lock Button: Moved Mouse To Lock Button And Clicked X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); AutoLockChampion = true; SetLiveStatusText("Champion has been locked.", Color.Green); } } }
private void SaveOptions() { Options.SummonerName = SummonerNameTextbox.Text; Options.Username = UsernameTextbox.Text; if (EncryptPasswordToggle.Checked) { Options.Password = Encryption.EncryptNewPassword(PasswordTextbox.Text); Options.EncryptedIV = Encryption.ConvertRijndaelIVToBase64(); Options.EncryptedKey = Encryption.ConvertRijndaelKeyToBase64(); } else { Options.Password = PasswordTextbox.Text; } Options.IsPasswordEncrypted = EncryptPasswordToggle.Checked; Options.LeagueExeDirectory = LeagueDirectoryTextbox.Text; Options.MatchType = MatchTypeCombobox.Text; Options.SummonerType = SummonerTypeCombobox.Text; Options.ChampionName = ChampionNameTextbox.Text; if (HelpFile.IsTextNumeric(ImageRecognitionIntervalTextbox.Text)) { Options.ImageRecognitionInterval = int.Parse(ImageRecognitionIntervalTextbox.Text); } Options.LoginUsernameCoordinates = CoordinatesLoginUsernameTextbox.Text; Options.LoginPasswordCoordinates = CoordinatesLoginPasswordTextbox.Text; Options.LoginButtonCoordinates = CoordinatesLoginButtonTextbox.Text; Options.PlayButtonCoordinates = CoordinatesPlayButtonTextbox.Text; Options.SummonersRiftCoordinates = CoordinatesSummonersMatchTextbox.Text; Options.ARAMMatchCoordinates = CoordinatesARAMMatchTextbox.Text; Options.BlindPickCoordinates = CoordinatesBlindPickTextbox.Text; Options.DraftPickCoordinates = CoordinatesDraftPickTextbox.Text; Options.RankedSoloDuoCoordinates = CoordinatesRankedSoloDuoTextbox.Text; Options.ConfirmButtonCoordinates = CoordinatesConfirmButtonTextbox.Text; Options.ChampionSearchTextboxCoordinates = CoordinatesChampionSearchTextbox.Text; Options.FirstChampionBoxCoordinates = CoordinatesFirstChampionBoxTextbox.Text; Options.LockButtonCoodinates = CoordinatesLockButtonTextbox.Text; }
private void Form1_Load(object sender, EventArgs e) { HelpFile.StartAppLog(); LoadOptions(); }
private async void ImageRecognitionOperationManager() { if (AutoStartLeagueToggle.Checked) { StartLeagueClient(); UncheckToggle_FromRunningThread(AutoStartLeagueToggle); } if (AutoLoginToggle.Checked) { HelpFile.Log("Starting Thread: " + ImageRecognitionLoginThread.Name); ImageRecognitionLoginThread.Start(); ImageRecognitionLoginThread.Join(); UncheckToggle_FromRunningThread(AutoLoginToggle); } if (AutoCreateMatchToggle.Checked) { if (Options.MatchType.Equals("Summoners Rift")) { HelpFile.Log("Starting Thread: " + ImageRecognitionCreateSummonersRiftThread.Name); ImageRecognitionCreateSummonersRiftThread.Start(); ImageRecognitionCreateSummonersRiftThread.Join(); UncheckToggle_FromRunningThread(AutoCreateMatchToggle); } if (Options.MatchType.Equals("ARAM")) { HelpFile.Log("Starting Thread: " + ImageRecognitionARAMThread.Name); ImageRecognitionARAMThread.Start(); ImageRecognitionARAMThread.Join(); UncheckToggle_FromRunningThread(AutoCreateMatchToggle); } } if (AutoAcceptToggle.Checked) { HelpFile.Log("Starting Thread: " + ImageRecognitionAcceptMatchThread.Name); ImageRecognitionAcceptMatchThread.Start(); if (!Options.ContiuouslyMonitorAcceptMatch) { ImageRecognitionAcceptMatchThread.Join(); } UncheckToggle_FromRunningThread(AutoAcceptToggle); } if (AutoSelectChampionToggle.Checked) { HelpFile.Log("Starting Thread: " + ImageRecognitionSelectChampionThread.Name); ImageRecognitionSelectChampionThread.Start(); ImageRecognitionSelectChampionThread.Join(); UncheckToggle_FromRunningThread(AutoSelectChampionToggle); } if (AutoLockChampionToggle.Checked) { HelpFile.Log("Starting Thread: " + ImageRecognitionLockChampionThread.Name); ImageRecognitionLockChampionThread.Start(); ImageRecognitionLockChampionThread.Join(); UncheckToggle_FromRunningThread(AutoLockChampionToggle); } }
public static void ClickLockButton() { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LockButtonCoodinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Lock Button: Moved Mouse To Lock Button And Clicked X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); }
private async void CreateSummonersRiftLobby() { bool clickedPlayButton = false; bool selectedSummonersRift = false; bool selectSummonerType = false; bool clickedConfirmButton = false; while (!clickedConfirmButton) { TakeFullDesktopScreenShot(); if (!clickedPlayButton) { clickedPlayButton = await ImageRecognition.AutoClickPlayButtonImageRecognition(); } if (clickedPlayButton) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.PlayButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Click Play Button: Clicked Play Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } TakeFullDesktopScreenShot(); if (!selectedSummonersRift) { selectedSummonersRift = await ImageRecognition.AutoChooseSummerRiftModeImageRecognition(); } if (selectedSummonersRift) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.SummonersRiftCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Pick Summoner Mode: Picked Summoner Rift X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } Console.WriteLine(Options.SummonerType); if (Options.SummonerType.Equals("Draft Pick")) { TakeFullDesktopScreenShot(); if (!selectSummonerType) { selectSummonerType = await ImageRecognition.AutoChooseSummersDraftPickImageRecognition(); } if (selectSummonerType) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.DraftPickCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Summoner Mode: Draft Pick X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } } if (Options.SummonerType.Equals("Blind Pick")) { TakeFullDesktopScreenShot(); if (!selectSummonerType) { selectSummonerType = await ImageRecognition.AutoChooseSummersBlindPickImageRecognition(); } if (selectSummonerType) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.BlindPickCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Summoner Mode: Blind Pick X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } } if (Options.SummonerType.Equals("Ranked Solo/Duo")) { TakeFullDesktopScreenShot(); if (!selectSummonerType) { selectSummonerType = await ImageRecognition.AutoChooseSummersRankedImageRecognition(); } if (selectSummonerType) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.RankedSoloDuoCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Summoner Mode: Ranked Pick X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); } } TakeFullDesktopScreenShot(); if (!clickedConfirmButton) { clickedConfirmButton = await ImageRecognition.AutoClickConfirmButtonImageRecognition(); } if (clickedConfirmButton) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.PlayButtonCoordinates); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Confirm Button: Clicked Confirm Button X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); AutoCreateSummonerRift = true; SetLiveStatusText("Created Summoner's Rift: " + Options.SummonerType + " room.", Color.Green); } } }
private void LeagueAIO_FormClosing(object sender, FormClosingEventArgs e) { SaveOptions(); HelpFile.EndAppLog(); HelpFile.WriteLogToText(); }
private async void LoginToLeague() { bool leagueFullyLoaded = false; bool rememberMeChecked = false; bool addedUsername = false; bool addedPassword = false; bool clickedSignIn = false; bool failLoggedIn = false; if (!CheckUsernamePasswordTextIsValid()) { MessageBox.Show(@"Please make sure you've added your Username and Password.\r\nPlease check the Auto Login tab.", "Unable To Login", MessageBoxButtons.OK, MessageBoxIcon.Error); SetLiveStatusText("Please double check the Username and Password.", Color.Green); return; } while (!leagueFullyLoaded) { leagueFullyLoaded = await CheckIfLeagueLoaded(); } TakeFullDesktopScreenShot(); rememberMeChecked = await ImageRecognition.RememberMeCheckedImageRecognition(); while (!clickedSignIn || !failLoggedIn) { if (rememberMeChecked) { TakeFullDesktopScreenShot(); if (!addedPassword) { addedPassword = await ImageRecognition.LoginPasswordImageRecognition(); } TakeFullDesktopScreenShot(); if (!addedPassword) { addedPassword = await ImageRecognition.LoginPasswordFocusedImageRecognition(); } if (addedPassword) { string password = Options.IsPasswordEncrypted ? Encryption.Decrypt(Options.Password, Encryption.ConvertRijndaelKeyToByte(Options.EncryptedKey), Encryption.ConvertRijndaelIVToByte(Options.EncryptedIV)) : Options.Password; int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LoginPasswordCoordinates); KeyboardEvents.SetClipboardText(password); HelpFile.Log("Login Password: Copied Text To Clipboard."); Thread.Sleep(Options.ImageRecognitionInterval); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Login Password: Moved Mouse To Textbox And Clicked X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Login Password: Pressed Control+V To Paste Password."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.ClearClipboard(); HelpFile.Log("Login Password: Cleared Clipboard Of Password."); } } else { TakeFullDesktopScreenShot(); if (!addedUsername) { addedUsername = await ImageRecognition.LoginUsernameImageRecognition(); } TakeFullDesktopScreenShot(); if (!addedUsername) { addedUsername = await ImageRecognition.LoginUsernameFocusedImageRecognition(); } if (addedUsername) { int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LoginUsernameCoordinates); KeyboardEvents.SetClipboardText(Options.Username); HelpFile.Log("Login Username: Copied Username To Clipboard."); Thread.Sleep(Options.ImageRecognitionInterval); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Login Username: Moved Mouse To And Clicked Username Textbox X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Login Username: Pressed Control+V To Paste Username."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.ClearClipboard(); HelpFile.Log("Login Username: Cleared Clipboard Of Username."); } TakeFullDesktopScreenShot(); if (!addedPassword) { addedPassword = await ImageRecognition.LoginPasswordImageRecognition(); } TakeFullDesktopScreenShot(); if (!addedPassword) { addedPassword = await ImageRecognition.LoginPasswordFocusedImageRecognition(); } if (addedPassword) { string password = Options.IsPasswordEncrypted ? Encryption.Decrypt(Options.Password, Encryption.ConvertRijndaelKeyToByte(Options.EncryptedKey), Encryption.ConvertRijndaelIVToByte(Options.EncryptedIV)) : Options.Password; int[] coordinates = HelpFile.GetXYCoordinatesRegex(Options.LoginPasswordCoordinates); KeyboardEvents.SetClipboardText(password); HelpFile.Log("Login Password: Copied Text To Clipboard."); Thread.Sleep(Options.ImageRecognitionInterval); MouseEvent.MoveMouseXYToAndClick(coordinates[0], coordinates[1]); HelpFile.Log("Login Password: Moved Mouse To Textbox And Clicked X:" + coordinates[0] + ", Y:" + coordinates[1] + "."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.PressControlV(); HelpFile.Log("Login Password: Pressed Control+V To Paste Password."); Thread.Sleep(Options.ImageRecognitionInterval); KeyboardEvents.ClearClipboard(); HelpFile.Log("Login Password: Cleared Clipboard Of Password."); } } if (addedPassword) { KeyboardEvents.PressEnter(); clickedSignIn = true; AutoLogin = true; return; } TakeFullDesktopScreenShot(); if (!failLoggedIn) { failLoggedIn = await ImageRecognition.LoginFailedImageRecognition(); } } if (failLoggedIn) { AutoLoginToggle.Checked = false; MessageBox.Show(@"Please make sure your Username and Password is correct.", "Unable To Login", MessageBoxButtons.OK, MessageBoxIcon.Error); SetLiveStatusText("Please double check the Username and Password.", Color.Green); return; } if (clickedSignIn) { SetLiveStatusText("Successfully logged into league.", Color.Green); AutoLogin = true; return; } }