Skip to content

Commit

Permalink
added auto RiotClientServices.exe search
Browse files Browse the repository at this point in the history
changed selectors so that filling works with all language clients
  • Loading branch information
MELVARDEV committed Jul 13, 2021
1 parent f940569 commit ec7e8a5
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 28 deletions.
21 changes: 11 additions & 10 deletions LeagueAccManager/AutoFill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -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) { }
Expand All @@ -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;
}
Expand All @@ -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) { }
Expand Down Expand Up @@ -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) { }
Expand All @@ -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) { }
Expand All @@ -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;
}
Expand All @@ -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) { }
Expand Down
5 changes: 4 additions & 1 deletion LeagueAccManager/LeaguePassManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="FlaUI.Core, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down Expand Up @@ -216,6 +219,6 @@
</Target>
<Import Project="..\packages\Interop.UIAutomationClient.10.18362.0\build\Interop.UIAutomationClient.targets" Condition="Exists('..\packages\Interop.UIAutomationClient.10.18362.0\build\Interop.UIAutomationClient.targets')" />
<PropertyGroup>
<PostBuildEvent>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)</PostBuildEvent>
<PostBuildEvent>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)</PostBuildEvent>
</PropertyGroup>
</Project>
58 changes: 43 additions & 15 deletions LeagueAccManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public MainWindow()
// -------------------

Settings.load(settings);
Settings.findRiotClientPath(settings);

// Show loading indicator if any taks are running
Task.Run(async () =>
Expand Down Expand Up @@ -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)
{

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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");

Expand All @@ -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)
Expand Down
45 changes: 43 additions & 2 deletions LeagueAccManager/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -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 = "";
Expand Down Expand Up @@ -65,7 +104,9 @@ public static void load(Settings settings)
}
}





}
}
}

0 comments on commit ec7e8a5

Please sign in to comment.