diff --git a/UWPHook/AppManager.cs b/UWPHook/AppManager.cs index ec2664e..3f69580 100644 --- a/UWPHook/AppManager.cs +++ b/UWPHook/AppManager.cs @@ -23,7 +23,15 @@ namespace UWPHook { var mgr = new ApplicationActivationManager(); uint processId; - mgr.ActivateApplication(uri, null, ActivateOptions.None, out processId); + + try + { + mgr.ActivateApplication(uri, null, ActivateOptions.None, out processId); + } + catch (Exception e) + { + throw new Exception("Error while trying to launch your app." + Environment.NewLine + e.Message); + } id = (int)processId; } diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs index 21aab51..1df1435 100644 --- a/UWPHook/GamesWindow.xaml.cs +++ b/UWPHook/GamesWindow.xaml.cs @@ -15,6 +15,7 @@ using VDFParser; using VDFParser.Models; using SharpSteam; using System.IO; +using System.Threading; namespace UWPHook { @@ -30,7 +31,37 @@ namespace UWPHook InitializeComponent(); Apps = new AppEntryModel(); listGames.ItemsSource = Apps.Entries; - this.Title = string.Join(";", Environment.GetCommandLineArgs()); + + //If null or 1, the app was launched normally + if (Environment.GetCommandLineArgs() != null) + { + //When length is 1, the only argument is the path where the app is installed + if (Environment.GetCommandLineArgs().Length > 1) + { + Launcher(); + } + } + } + + private void Launcher() + { + this.Title = "UWPHook: Playing a game"; + //Hide the window so the app is launched seamless + this.Hide(); + try + { + //The only other parameter Steam will send is the app AUMID + AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]); + while (AppManager.IsRunning()) + { + Thread.Sleep(5000); + } + } + catch (Exception e) + { + this.Show(); + MessageBox.Show(e.Message, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Warning); + } } private void ExportButton_Click(object sender, RoutedEventArgs e) @@ -80,6 +111,7 @@ namespace UWPHook foreach (var app in installedApps) { + //Remove end lines from the String and split both values var valor = app.Replace("\r\n", "").Split('|'); if (!String.IsNullOrEmpty(valor[0])) { diff --git a/UWPHook/MainWindow.xaml.cs b/UWPHook/MainWindow.xaml.cs index de9b802..6f09b2a 100644 --- a/UWPHook/MainWindow.xaml.cs +++ b/UWPHook/MainWindow.xaml.cs @@ -67,7 +67,6 @@ namespace UWPHook } catch (Exception ex) { - throw new Exception("Error while trying to launch your game" + Environment.NewLine + ex.Message); } break; } diff --git a/UWPHook/Settings.cs b/UWPHook/Settings.cs new file mode 100644 index 0000000..724e521 --- /dev/null +++ b/UWPHook/Settings.cs @@ -0,0 +1,28 @@ +namespace UWPHook.Properties { + + + // This class allows you to handle specific events on the settings class: + // The SettingChanging event is raised before a setting's value is changed. + // The PropertyChanged event is raised after a setting's value is changed. + // The SettingsLoaded event is raised after the setting values are loaded. + // The SettingsSaving event is raised before the setting values are saved. + internal sealed partial class Settings { + + public Settings() { + // // To add event handlers for saving and changing settings, uncomment the lines below: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Add code to handle the SettingChangingEvent event here. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Add code to handle the SettingsSaving event here. + } + } +} diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj index 079d5f1..8abce32 100644 --- a/UWPHook/UWPHook.csproj +++ b/UWPHook/UWPHook.csproj @@ -99,6 +99,7 @@ GamesWindow.xaml + Designer MSBuild:Compile