diff --git a/UWPHook/App.xaml.cs b/UWPHook/App.xaml.cs
index 2d70dfd..a15aa95 100644
--- a/UWPHook/App.xaml.cs
+++ b/UWPHook/App.xaml.cs
@@ -7,5 +7,6 @@ namespace UWPHook
///
public partial class App : Application
{
+
}
}
diff --git a/UWPHook/AppManager.cs b/UWPHook/AppManager.cs
new file mode 100644
index 0000000..6bdb23b
--- /dev/null
+++ b/UWPHook/AppManager.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UWPHook
+{
+ class AppManager
+ {
+ private int id;
+
+ public void LaunchUWPApp(string uri)
+ {
+ var mgr = new ApplicationActivationManager();
+ uint processId;
+ mgr.ActivateApplication(uri, null, ActivateOptions.None, out processId);
+
+ id = (int)processId;
+ }
+
+ public Boolean IsRunning()
+ {
+ if (id == 0)
+ {
+ return false;
+ }
+ try
+ {
+ Process.GetProcessById(id);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ public enum ActivateOptions
+ {
+ None = 0x00000000, // No flags set
+ DesignMode = 0x00000001, // The application is being activated for design mode, and thus will not be able to
+ // to create an immersive window. Window creation must be done by design tools which
+ // load the necessary components by communicating with a designer-specified service on
+ // the site chain established on the activation manager. The splash screen normally
+ // shown when an application is activated will also not appear. Most activations
+ // will not use this flag.
+ NoErrorUI = 0x00000002, // Do not show an error dialog if the app fails to activate.
+ NoSplashScreen = 0x00000004, // Do not show the splash screen when activating the app.
+ }
+
+ [ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IApplicationActivationManager
+ {
+ // Activates the specified immersive application for the "Launch" contract, passing the provided arguments
+ // string into the application. Callers can obtain the process Id of the application instance fulfilling this contract.
+ IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
+ IntPtr ActivateForFile([In] String appUserModelId, [In] [MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)] /*IShellItemArray* */ IShellItemArray itemArray, [In] String verb, [Out] out UInt32 processId);
+ IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
+ }
+
+ [ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]//Application Activation Manager
+ class ApplicationActivationManager : IApplicationActivationManager
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
+ public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public extern IntPtr ActivateForFile([In] String appUserModelId, [In] [MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)] /*IShellItemArray* */ IShellItemArray itemArray, [In] String verb, [Out] out UInt32 processId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
+ }
+
+ [ComImport]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
+ interface IShellItem
+ {
+ }
+
+ [ComImport]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid("b63ea76d-1f85-456f-a19c-48159efa858b")]
+ interface IShellItemArray
+ {
+ }
+}
diff --git a/UWPHook/MainWindow.xaml b/UWPHook/MainWindow.xaml
index 7c97ea1..6679be8 100644
--- a/UWPHook/MainWindow.xaml
+++ b/UWPHook/MainWindow.xaml
@@ -5,11 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UWPHook"
mc:Ignorable="d"
- Title="UWPHook" Height="350" Width="525" Loaded="Window_Loaded" Icon="1_cJz_icon.ico">
+ Title="UWPHook" Height="600" Width="800" Loaded="Window_Loaded" Icon="1_cJz_icon.ico">
-
-
+
+
@@ -20,7 +20,11 @@
-
+
@@ -32,18 +36,17 @@
-
+
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/UWPHook/MainWindow.xaml.cs b/UWPHook/MainWindow.xaml.cs
index f67b20b..241c6e9 100644
--- a/UWPHook/MainWindow.xaml.cs
+++ b/UWPHook/MainWindow.xaml.cs
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics;
+using System.IO;
+using System.Threading;
using System.Windows;
namespace UWPHook
@@ -10,33 +12,61 @@ namespace UWPHook
public partial class MainWindow : Window
{
GameModel gamesView;
+ AppManager manager;
+
public MainWindow()
{
InitializeComponent();
+ gamesView = new GameModel();
+
+ if (Environment.GetCommandLineArgs() != null)
+ {
+ if (Environment.GetCommandLineArgs().Length > 1)
+ {
+ manager = new AppManager();
+ try
+ {
+ this.Hide();
+
+ Launch_Game(String.Join(" ", Environment.GetCommandLineArgs()));
+ while (manager.IsRunning())
+ {
+ Thread.Sleep(5000);
+ }
+
+ this.Close();
+ }
+ catch (Exception e)
+ {
+ this.Show();
+ MessageBox.Show(e.Message);
+ }
+ }
+ }
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- gamesView = new GameModel();
listView.ItemsSource = gamesView.games;
+ }
- var argument = Environment.GetCommandLineArgs();
- string argumentGame = "";
- for (int i = 1; i < argument.Length; i++)
- {
- argumentGame += argument[i] + " ";
- }
-
- if (argument != null)
+ private void Launch_Game(string game_name)
+ {
+ //Remove startup path from parameters to get the game name sent from startup options from Steam
+ game_name = game_name.Remove(0, (System.Reflection.Assembly.GetExecutingAssembly().Location + " ").Length);
+ foreach (Game game in gamesView.games)
{
- foreach (Game game in gamesView.games)
+ if (game.game_alias.ToLower() == game_name.ToLower())
{
- if (game.game_alias.ToLower() == argumentGame.ToLower().Trim())
+ try
+ {
+ manager.LaunchUWPApp(game.game_path);
+ }
+ catch (Exception ex)
{
- Process.Start(@"shell:AppsFolder\" + game.game_path);
- this.Title = "UWPHook - Now Playing :" + game.game_alias;
- break;
+ throw new Exception("Error while trying to launch your game" + Environment.NewLine + ex.Message);
}
+ break;
}
}
}
diff --git a/UWPHook/ProcessManager.cs b/UWPHook/ProcessManager.cs
new file mode 100644
index 0000000..fa12dd3
--- /dev/null
+++ b/UWPHook/ProcessManager.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UWPHook
+{
+ class ProccessManager
+ {
+ }
+}
diff --git a/UWPHook/Properties/AssemblyInfo.cs b/UWPHook/Properties/AssemblyInfo.cs
index e0b4a07..cfb6871 100644
--- a/UWPHook/Properties/AssemblyInfo.cs
+++ b/UWPHook/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
diff --git a/UWPHook/Properties/Resources.Designer.cs b/UWPHook/Properties/Resources.Designer.cs
index b96082f..930a76f 100644
--- a/UWPHook/Properties/Resources.Designer.cs
+++ b/UWPHook/Properties/Resources.Designer.cs
@@ -8,10 +8,10 @@
//
//------------------------------------------------------------------------------
-namespace UWPHook.Properties
-{
-
-
+namespace UWPHook.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -22,48 +22,40 @@ namespace UWPHook.Properties
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UWPHook.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
diff --git a/UWPHook/Properties/Resources.resx b/UWPHook/Properties/Resources.resx
index af7dbeb..2f96abe 100644
--- a/UWPHook/Properties/Resources.resx
+++ b/UWPHook/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,10 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
\ No newline at end of file
diff --git a/UWPHook/Resources/delete.png b/UWPHook/Resources/delete.png
new file mode 100644
index 0000000..70293b2
Binary files /dev/null and b/UWPHook/Resources/delete.png differ
diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj
index 3e478c5..5178d95 100644
--- a/UWPHook/UWPHook.csproj
+++ b/UWPHook/UWPHook.csproj
@@ -14,6 +14,21 @@
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
true
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
AnyCPU
@@ -35,7 +50,10 @@
4
- 1_cJz_icon.ico
+ hook_icon.ico
+
+
+ UWPHook.App
@@ -44,6 +62,7 @@
+
@@ -70,6 +89,7 @@
App.xaml
Code
+
MainWindow.xaml
@@ -93,6 +113,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+ Designer
PreserveNewest
@@ -108,7 +129,22 @@
-
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.6.1 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+