Pass secondary args to launched app

pull/70/head
Brian Lima 3 years ago
parent 7783a815a3
commit 1ef8c073b7

@ -20,14 +20,23 @@ namespace UWPHook
/// Launch a UWP App using a ApplicationActivationManager and sets a internal id to launched proccess id
/// </summary>
/// <param name="aumid">The AUMID of the app to launch</param>
public static void LaunchUWPApp(string aumid)
public static void LaunchUWPApp(string[] args)
{
string aumid = args[1]; // We receive the args from Steam,
// 0 is application location,
// 1 is the aumid, the rest are extras
var mgr = new ApplicationActivationManager();
uint processId;
string extra_args = String.Join(" ", args.Skip(2)
.Take(args.Length - 2)
.Select(eachElement => eachElement.Clone()
).ToArray());
try
{
mgr.ActivateApplication(aumid, null, ActivateOptions.None, out processId);
mgr.ActivateApplication(aumid, extra_args, ActivateOptions.None, out processId);
//Bring the launched app to the foreground, this fixes in-home streaming
id = (int)processId;

@ -32,14 +32,15 @@ namespace UWPHook
{
InitializeComponent();
Apps = new AppEntryModel();
var args = Environment.GetCommandLineArgs();
//If null or 1, the app was launched normally
if (Environment.GetCommandLineArgs() != null)
if (args != null)
{
//When length is 1, the only argument is the path where the app is installed
if (Environment.GetCommandLineArgs().Length > 1)
{
_ = LauncherAsync();
_ = LauncherAsync(args);
}
}
}
@ -53,7 +54,7 @@ namespace UWPHook
await Task.Delay(10000);
}
private async Task LauncherAsync()
private async Task LauncherAsync(string[] args)
{
FullScreenLauncher launcher = null;
//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 @@ namespace UWPHook
}
//The only other parameter Steam will send is the app AUMID
AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]);
AppManager.LaunchUWPApp(args);
//While the current launched app is running, sleep for n seconds and then check again
while (AppManager.IsRunning())

Loading…
Cancel
Save