diff --git a/LeagueAccManager/AutoFill.cs b/LeagueAccManager/AutoFill.cs index 290d8fa..8a88392 100644 --- a/LeagueAccManager/AutoFill.cs +++ b/LeagueAccManager/AutoFill.cs @@ -49,7 +49,8 @@ public static void lol(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("USERNAME")).AsTextBox().Text = result.UserName; + + mainWindow.FindFirstDescendant(cf.ByAutomationId("username")).AsTextBox().Text = result.UserName; tryAgain = false; } catch (Exception e) { } @@ -63,7 +64,7 @@ public static void lol(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("PASSWORD")).AsTextBox().Text = result.Password; + mainWindow.FindFirstDescendant(cf.ByAutomationId("password")).AsTextBox().Text = result.Password; tryAgain = false; } catch (Exception e) { } @@ -75,9 +76,9 @@ public static void lol(Process pr) { try { - if (mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().IsToggled != (window as MainWindow).settings.staySignedIn) + if (mainWindow.FindFirstDescendant(cf.ByAutomationId("remember-me")).AsCheckBox().IsToggled != (window as MainWindow).settings.staySignedIn) { - mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().Toggle(); + mainWindow.FindFirstDescendant(cf.ByAutomationId("remember-me")).AsCheckBox().Toggle(); } tryAgain = false; } @@ -89,7 +90,7 @@ public static void lol(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("Sign in").And(cf.ByControlType(ControlType.Button))).AsButton().Invoke(); + mainWindow.FindAt(TreeScope.Descendants, 4, cf.ByControlType(ControlType.Button)).AsButton().Invoke(); tryAgain = false; } catch (Exception e) { } @@ -143,7 +144,7 @@ public static void valorant(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("USERNAME")).AsTextBox().Text = result.UserName; + mainWindow.FindFirstDescendant(cf.ByAutomationId("username")).AsTextBox().Text = result.UserName; tryAgain = false; } catch (Exception e) { } @@ -158,7 +159,7 @@ public static void valorant(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("PASSWORD")).AsTextBox().Text = result.Password; + mainWindow.FindFirstDescendant(cf.ByAutomationId("password")).AsTextBox().Text = result.Password; tryAgain = false; } catch (Exception e) { } @@ -171,9 +172,9 @@ public static void valorant(Process pr) { try { - if (mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().IsToggled != (window as MainWindow).settings.staySignedIn) + if (mainWindow.FindFirstDescendant(cf.ByAutomationId("remember-me")).AsCheckBox().IsToggled != (window as MainWindow).settings.staySignedIn) { - mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().Toggle(); + mainWindow.FindFirstDescendant(cf.ByAutomationId("remember-me")).AsCheckBox().Toggle(); } tryAgain = false; } @@ -186,7 +187,7 @@ public static void valorant(Process pr) { try { - mainWindow.FindFirstDescendant(cf.ByName("Sign in").And(cf.ByControlType(ControlType.Button))).AsButton().Invoke(); + mainWindow.FindAt(TreeScope.Descendants, 4, cf.ByControlType(ControlType.Button)).AsButton().Invoke(); tryAgain = false; } catch (Exception e) { } diff --git a/LeagueAccManager/LeaguePassManager.csproj b/LeagueAccManager/LeaguePassManager.csproj index 40e37fc..bfc12e5 100644 --- a/LeagueAccManager/LeaguePassManager.csproj +++ b/LeagueAccManager/LeaguePassManager.csproj @@ -80,6 +80,9 @@ Properties\app.manifest + + Always + @@ -216,6 +219,6 @@ - if $(ConfigurationName) == Release (powershell.exe -Command $null=mkdir '$(SolutionDir)PublishOutput'; Compress-Archive -CompressionLevel Optimal -Path '$(TargetDir)*.dll','$(TargetDir)*.exe', '$(TargetDir)*.config' -DestinationPath '$(SolutionDir)PublishOutput\release.zip' -Force) + if $(ConfigurationName) == Release (powershell.exe -Command $null=mkdir '$(SolutionDir)PublishOutput'; Remove-Item -Path '$(SolutionDir)PublishOutput\release.zip'; Compress-Archive -CompressionLevel Optimal -Path '$(TargetDir)*.dll','$(TargetDir)*.exe', '$(TargetDir)*.config' -DestinationPath '$(SolutionDir)PublishOutput\release.zip' -Force) \ No newline at end of file diff --git a/LeagueAccManager/MainWindow.xaml.cs b/LeagueAccManager/MainWindow.xaml.cs index 2b5711d..2b5040d 100644 --- a/LeagueAccManager/MainWindow.xaml.cs +++ b/LeagueAccManager/MainWindow.xaml.cs @@ -219,6 +219,7 @@ public MainWindow() // ------------------- Settings.load(settings); + Settings.findRiotClientPath(settings); // Show loading indicator if any taks are running Task.Run(async () => @@ -253,6 +254,22 @@ public MainWindow() } + void riotClientPathDialog() + { + while (String.IsNullOrWhiteSpace(settings.riotClientPath)) + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.AddExtension = true; + openFileDialog.DefaultExt = "exe"; + openFileDialog.Filter = "RiotClientServices.exe|RiotClientServices.exe"; + if (openFileDialog.ShowDialog() == true) + { + settings.riotClientPath = openFileDialog.FileName; + settings.save(); + } + } + } + private async void fillButton_Click(object sender, RoutedEventArgs e) { @@ -292,6 +309,12 @@ private async void fillButton_Click(object sender, RoutedEventArgs e) } else if (settings.autoOpenClient) { + if (string.IsNullOrEmpty(settings.riotClientPath)) + { + riotClientPathDialog(); + } + + string sessionFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Riot Games" + Path.DirectorySeparatorChar + "Riot Client" + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "RiotClientPrivateSettings.yaml"); try @@ -305,7 +328,15 @@ private async void fillButton_Click(object sender, RoutedEventArgs e) Console.WriteLine(ex.Message); } - leagueClientProcess = Process.Start(settings.riotClientPath, "--launch-product=league_of_legends --launch-patchline=live"); + try + { + leagueClientProcess = Process.Start(settings.riotClientPath, "--launch-product=league_of_legends --launch-patchline=live"); + } + catch (Exception ex) + { + riotClientPathDialog(); + leagueClientProcess = Process.Start(settings.riotClientPath, "--launch-product=league_of_legends --launch-patchline=live"); + } Process[] pname = Process.GetProcessesByName("RiotClientUx"); while (pname.Length == 0) @@ -378,20 +409,9 @@ private async void valorantFillButton_Click(object sender, RoutedEventArgs e) } else if (settings.autoOpenClient) { - while (String.IsNullOrWhiteSpace(settings.riotClientPath)) + if (string.IsNullOrEmpty(settings.riotClientPath)) { - - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.AddExtension = true; - openFileDialog.DefaultExt = "exe"; - openFileDialog.Filter = "RiotClientServices.exe|RiotClientServices.exe"; - if (openFileDialog.ShowDialog() == true) - { - - settings.riotClientPath = openFileDialog.FileName; - settings.save(); - - } + riotClientPathDialog(); } string sessionFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Riot Games" + Path.DirectorySeparatorChar + "Riot Client" + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "RiotClientPrivateSettings.yaml"); @@ -406,7 +426,15 @@ private async void valorantFillButton_Click(object sender, RoutedEventArgs e) Console.WriteLine(ex.Message); } - valorantClientProcess = Process.Start(settings.riotClientPath, "--launch-product=valorant --launch-patchline=live"); + try + { + valorantClientProcess = Process.Start(settings.riotClientPath, "--launch-product=valorant --launch-patchline=live"); + } + catch (Exception ex) + { + riotClientPathDialog(); + valorantClientProcess = Process.Start(settings.riotClientPath, "--launch-product=valorant --launch-patchline=live"); + } Process[] pname = Process.GetProcessesByName("RiotClientUx"); while (pname.Length == 0) diff --git a/LeagueAccManager/Settings.cs b/LeagueAccManager/Settings.cs index ce266ae..a10d2e0 100644 --- a/LeagueAccManager/Settings.cs +++ b/LeagueAccManager/Settings.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Microsoft.Win32; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -25,6 +26,44 @@ public void save() File.WriteAllText("settings.json", JsonConvert.SerializeObject(this)); } + public static void findRiotClientPath(Settings settings) + { + // Try to detect RiotClientServices.exe location + if (string.IsNullOrEmpty(settings.riotClientPath)) + { + + string valueName = "UninstallString"; + string lolKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Riot Game league_of_legends.live"; + string valorantKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Riot Game valorant.live"; + + try + { + using (RegistryKey key = Registry.CurrentUser.OpenSubKey(lolKey)) + { + if (key != null) + { + string uninstallString = (string)key.GetValue(valueName); + string path = uninstallString.Split('"')[1]; + settings.riotClientPath = path; + settings.save(); + } + else + { + using (RegistryKey valKey = Registry.CurrentUser.OpenSubKey(valorantKey)) + { + string uninstallString = (string)valKey.GetValue(valueName); + string path = uninstallString.Split('"')[1]; + settings.riotClientPath = path; + settings.save(); + } + } + } + } + catch (Exception ex) { } + + } + } + public static void load(Settings settings) { string settingsJson = ""; @@ -65,7 +104,9 @@ public static void load(Settings settings) } } - + + + } } }