Skip to content

Commit 1ef8c07

Browse files
committed
Pass secondary args to launched app
1 parent 7783a81 commit 1ef8c07

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

UWPHook/AppManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ static class AppManager
2020
/// Launch a UWP App using a ApplicationActivationManager and sets a internal id to launched proccess id
2121
/// </summary>
2222
/// <param name="aumid">The AUMID of the app to launch</param>
23-
public static void LaunchUWPApp(string aumid)
23+
public static void LaunchUWPApp(string[] args)
2424
{
25+
string aumid = args[1]; // We receive the args from Steam,
26+
// 0 is application location,
27+
// 1 is the aumid, the rest are extras
28+
2529
var mgr = new ApplicationActivationManager();
2630
uint processId;
2731

32+
string extra_args = String.Join(" ", args.Skip(2)
33+
.Take(args.Length - 2)
34+
.Select(eachElement => eachElement.Clone()
35+
).ToArray());
36+
2837
try
2938
{
30-
mgr.ActivateApplication(aumid, null, ActivateOptions.None, out processId);
39+
mgr.ActivateApplication(aumid, extra_args, ActivateOptions.None, out processId);
3140

3241
//Bring the launched app to the foreground, this fixes in-home streaming
3342
id = (int)processId;

UWPHook/GamesWindow.xaml.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ public GamesWindow()
3232
{
3333
InitializeComponent();
3434
Apps = new AppEntryModel();
35+
var args = Environment.GetCommandLineArgs();
3536

3637
//If null or 1, the app was launched normally
37-
if (Environment.GetCommandLineArgs() != null)
38+
if (args != null)
3839
{
3940
//When length is 1, the only argument is the path where the app is installed
4041
if (Environment.GetCommandLineArgs().Length > 1)
4142
{
42-
_ = LauncherAsync();
43+
_ = LauncherAsync(args);
4344
}
4445
}
4546
}
@@ -53,7 +54,7 @@ async Task LaunchDelay()
5354
await Task.Delay(10000);
5455
}
5556

56-
private async Task LauncherAsync()
57+
private async Task LauncherAsync(string[] args)
5758
{
5859
FullScreenLauncher launcher = null;
5960
//So, for some reason, Steam is now stopping in-home streaming if the launched app is minimized, so not hiding UWPHook's window is doing the trick for now
@@ -86,7 +87,7 @@ private async Task LauncherAsync()
8687
}
8788

8889
//The only other parameter Steam will send is the app AUMID
89-
AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]);
90+
AppManager.LaunchUWPApp(args);
9091

9192
//While the current launched app is running, sleep for n seconds and then check again
9293
while (AppManager.IsRunning())

0 commit comments

Comments
 (0)