Skip to content

Commit

Permalink
- Changed fill method
Browse files Browse the repository at this point in the history
- Settings rearrangement
- Context menu for account file
  • Loading branch information
MELVARDEV committed Jul 3, 2021
1 parent e837d56 commit edb44b4
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 9 deletions.
15 changes: 15 additions & 0 deletions LPM Installer/InstallScript.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Setup]
AppName=Inno_Setup_Project
AppVersion=1.0
DefaultDirName={pf}\Inno_Setup_Project
DefaultGroupName=Inno_Setup_Project
UninstallDisplayIcon={app}\Inno_Setup_Project.exe
Compression=lzma2
SolidCompression=yes
OutputDir=Output

[Files]
Source: "InstallScript.iss"; DestDir: "{app}"

[Icons]
Name: "{group}\Inno_Setup_Project"; Filename: "{app}\Inno_Setup_Project.exe"
25 changes: 25 additions & 0 deletions LPM Installer/LPM Installer.innoproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>1.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>b57d6b18-a896-4a44-8e87-9af3da8986a6</ProjectGuid>
<AssemblyName>LPM Installer</AssemblyName>
<Name>LPM Installer</Name>
<RootNamespace>LPM Installer</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>
</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>
</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="InstallScript.iss">
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\InnoSetupTools\InnoSetupProject.targets" />
</Project>
2 changes: 2 additions & 0 deletions League Pass Manager/League Pass Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FlaUI.Core" Version="3.2.0" />
<PackageReference Include="FlaUI.UIA3" Version="3.2.0" />
<PackageReference Include="InputSimulator" Version="1.0.4" />
<PackageReference Include="InputSimulatorPlus" Version="1.0.7" />
<PackageReference Include="MahApps.Metro" Version="2.4.5" />
Expand Down
21 changes: 17 additions & 4 deletions League Pass Manager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,26 @@
<Grid>
<StackPanel HorizontalAlignment="Left" Width="196" Margin="6,7,0,0">
<Button Content="Change password file location" Height="28" Click="Button_Click_3"/>
<Button x:Name="copyDataToClipboardBtn" Content="Copy data to clipboard" Margin="0,6,0,0" Click="copyDataToClipboardBtn_Click"/>
<Button Content="Change encryption key " Margin="0,6,0,0" Click="Button_Click_2"/>
<mah:ToggleSwitch x:Name="exitAfterFillingSwitch" Header="Exit after filling data" Height="100" OnContent="Yes" OffContent="No" Width="100" Margin="0,10,0,0" HorizontalAlignment="Center" IsEnabled="True" Toggled="exitAfterFillingSwitch_Toggled"/>
<Button x:Name="copyDataToClipboardBtn" Content="Copy data to clipboard" Margin="0,6,0,0" Click="copyDataToClipboardBtn_Click"/>

<mah:ToggleSwitch x:Name="exitAfterFillingSwitch" Header="Exit after filling data" Height="59" OnContent="Yes" OffContent="No" Width="100" Margin="0,10,0,0" HorizontalAlignment="Center" IsEnabled="True" Toggled="exitAfterFillingSwitch_Toggled"/>
<mah:ToggleSwitch x:Name="staySignedInSwitch" Header="Stay signed in" Height="59" OnContent="Yes" OffContent="No" Width="100" IsEnabled="True" Toggled="staySignedInSwitch_Toggled" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel HorizontalAlignment="Stretch" Margin="215,7,8,0">
<TextBox x:Name="passFileLocation" Text="" TextWrapping="Wrap" HorizontalAlignment="Stretch" IsReadOnly="True" Height="28" TextChanged="passFileLocation_TextChanged" />
<TextBox x:Name="newEncryptionKey" Text="" TextWrapping="Wrap" Margin="0,39,0,0" Height="27.3" HorizontalAlignment="Stretch" mah:TextBoxHelper.Watermark="New encryption key..."/>
<TextBox x:Name="passFileLocation" Text="" TextWrapping="Wrap" HorizontalAlignment="Stretch" IsReadOnly="True" Height="28" TextChanged="passFileLocation_TextChanged">
<TextBox.ContextMenu>
<ContextMenu Name="cMenu1" >

<MenuItem Header="Copy Path" Name="cMenuItemCopy" Click="cMenuItemCopy_Click" />
<MenuItem Header="Open directory in explorer" Name="cMenuItemOpenDir" Click="cMenuItemOpenDir_Click" />

</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
<TextBox x:Name="newEncryptionKey" Text="" TextWrapping="Wrap" Margin="0,6,0,0" Height="27.3" HorizontalAlignment="Stretch" mah:TextBoxHelper.Watermark="New encryption key..."/>
<Button x:Name="openConfigFile" Content="Open config file" Margin="0,6,0,0" IsEnabled="False"/>

<mah:ToggleSwitch x:Name="autoOpenClientSwitch" Header="Auto open client" Height="56" Width="107" Margin="17,12,0,0" HorizontalAlignment="Left" OnContent="Yes" OffContent="No" Toggled="autoOpenClientSwitch_Toggled" HorizontalContentAlignment="Left" MinWidth="104"/>
<Label Content="Delay after launching client" Margin="11,3,0,0" HorizontalAlignment="Center" />
<Slider x:Name="delaySlider" Margin="10,1,8,0" Maximum="5000" Value="2000" ValueChanged="delaySlider_ValueChanged" MouseUp="delaySlider_MouseUp" Thumb.DragCompleted="delaySlider_DragCompleted" />
Expand Down
188 changes: 183 additions & 5 deletions League Pass Manager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
using System.ComponentModel;
using Microsoft.Win32;
using Path = System.IO.Path;
using FlaUI.UIA3;
using FlaUI.Core.Conditions;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Tools;
using FlaUI.Core.Definitions;

namespace League_Pass_Manager
{
Expand Down Expand Up @@ -64,7 +69,8 @@ public class Settings
public bool exitAfterFill { get; set; } = false;
public string leagueClientPath { get; set; } = null;
public bool autoOpenClient { get; set; } = false;
public int launchDelay { get; set; } = 2000;
public bool staySignedIn { get; set; } = true;
public int launchDelay { get; set; } = 0;
}

public class Account
Expand Down Expand Up @@ -159,6 +165,7 @@ public void loadSettings()

autoOpenClientSwitch.IsOn = settings.autoOpenClient;
exitAfterFillingSwitch.IsOn = settings.exitAfterFill;
staySignedInSwitch.IsOn = settings.staySignedIn;
delaySlider.Value = Convert.ToDouble(settings.launchDelay);
launchDelayLabel.Content = settings.launchDelay.ToString() + " ms";
}
Expand All @@ -178,9 +185,125 @@ public MainWindow()
passFileLocation.Text = settings.filePath;
}

public void wait(int milliseconds)
{
var timer1 = new System.Windows.Forms.Timer();
if (milliseconds == 0 || milliseconds < 0) return;

// Console.WriteLine("start wait timer");
timer1.Interval = milliseconds;
timer1.Enabled = true;
timer1.Start();

timer1.Tick += (s, e) =>
{
timer1.Enabled = false;
timer1.Stop();
// Console.WriteLine("stop wait timer");
};

while (timer1.Enabled)
{

}
}

void simulateFill(Process pr)
{
IntPtr hWnd = pr.MainWindowHandle;

var application = FlaUI.Core.Application.Attach(pr.Id);


var mainWindow = application.GetMainWindow(new UIA3Automation());
//mainWindow.FindFirstDescendant();

FlaUI.Core.Input.Wait.UntilResponsive(mainWindow.FindFirstChild(), TimeSpan.FromMilliseconds(5000));

// MessageBox.Show(mainWindow.Title);

ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary());
Account selectedAccount = new Account();

try
{
selectedAccount = (Account)datagrid1.SelectedItem;
}
catch (Exception exce)
{
MessageBox.Show("You need to select an account first!");
return;
}

Account result = accounts.Find(x => x.userName == selectedAccount.userName);

bool tryAgain = true;
if (!String.IsNullOrEmpty(result.userName))
{
while (tryAgain)
{
try
{
mainWindow.FindFirstDescendant(cf.ByName("USERNAME")).AsTextBox().Text = result.userName;

tryAgain = false;
}
catch (Exception e) {}
}
}


tryAgain = true;
if (!String.IsNullOrEmpty(result.password))
{
while (tryAgain)
{
try
{
mainWindow.FindFirstDescendant(cf.ByName("PASSWORD")).AsTextBox().Text = result.password;
tryAgain = false;
}
catch (Exception e) { }
}
}


tryAgain = true;
while (tryAgain)
{
try
{
if (mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().IsToggled != settings.staySignedIn)
{
mainWindow.FindFirstDescendant(cf.ByName("Stay signed in")).AsCheckBox().Toggle();
}
tryAgain = false;
}
catch (Exception e) { }
}


tryAgain = true;
while (tryAgain)
{
try
{
mainWindow.FindFirstDescendant(cf.ByName("Sign in")).AsButton().Invoke();
tryAgain = false;
}
catch (Exception e) { }
}


if (settings.exitAfterFill)
{

this.Close();

}
return;


/*IntPtr hWnd = pr.MainWindowHandle;
//ShowWindow(hWnd, 3);
SetForegroundWindow(hWnd);
var inputSimulator = new InputSimulator();
Expand Down Expand Up @@ -217,7 +340,7 @@ void simulateFill(Process pr)
this.Close();
}
return;
return;*/
}

private async void Button_Click(object sender, RoutedEventArgs e)
Expand All @@ -236,6 +359,7 @@ private async void Button_Click(object sender, RoutedEventArgs e)
if (leagueClientProcess != null)
{
simulateFill(leagueClientProcess);

} else if (settings.autoOpenClient)
{

Expand Down Expand Up @@ -265,10 +389,29 @@ private async void Button_Click(object sender, RoutedEventArgs e)
}




// MessageBox.Show(leagueClientProcess.Id.ToString());



var mainWindowTitle = pname[0].MainWindowTitle;
while (mainWindowTitle != "Riot Client")
{
await Task.Delay(200);
Process[] proc = Process.GetProcessesByName("RiotClientUx");
while (proc.Length == 0)
{
proc = Process.GetProcessesByName("RiotClientUx");
}
mainWindowTitle = proc[0].MainWindowTitle;
if(proc[0].MainWindowTitle == "Riot Client")
{
pname[0] = proc[0];
}
}
await Task.Delay(settings.launchDelay);
simulateFill(leagueClientProcess);
// MessageBox.Show(pname[0].MainWindowTitle);
simulateFill(pname[0]);
} else
{
MessageBox.Show("League of Legends login screen not found...");
Expand Down Expand Up @@ -449,5 +592,40 @@ private void delaySlider_DragCompleted(object sender, System.Windows.Controls.Pr
{
saveSettings();
}

private void staySignedInSwitch_Toggled(object sender, RoutedEventArgs e)
{
settings.staySignedIn = staySignedInSwitch.IsOn;
saveSettings();
}

private void cMenuItemCopy_Click(object sender, RoutedEventArgs e)
{

try
{
Clipboard.SetText(Path.Join(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), settings.filePath));
}
catch (Exception ex) { }

}

private void cMenuItemOpenDir_Click(object sender, RoutedEventArgs e)
{
try
{
string filePath = Path.Join(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), settings.filePath);

if (!File.Exists(filePath))
{
return;
}

string argument = "/select, \"" + filePath + "\"";
System.Diagnostics.Process.Start("explorer.exe", argument);
}
catch (Exception ex) { }

}
}
}

0 comments on commit edb44b4

Please sign in to comment.