diff --git a/ShareX.DesktopBridgeHelper/App.config b/ShareX.DesktopBridgeHelper/App.config new file mode 100644 index 000000000..bae5d6d81 --- /dev/null +++ b/ShareX.DesktopBridgeHelper/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ShareX.DesktopBridgeHelper/Program.cs b/ShareX.DesktopBridgeHelper/Program.cs new file mode 100644 index 000000000..bda8aca1f --- /dev/null +++ b/ShareX.DesktopBridgeHelper/Program.cs @@ -0,0 +1,109 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2017 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using System; +using System.Diagnostics; +using System.IO; +using System.Threading.Tasks; +using Windows.ApplicationModel; + +namespace DesktopBridgeHelper +{ + internal class Program + { + private const string TaskID = "ShareX"; + + private static int Main(string[] args) + { + return MainAsync(args).GetAwaiter().GetResult(); + } + + private async static Task MainAsync(string[] args) + { + try + { + if (args.Length > 0) + { + string argument = args[0]; + + if (argument.Equals("-StartupState", StringComparison.InvariantCultureIgnoreCase)) + { + return (int)await GetStartupState(); + } + else if (argument.Equals("-StartupEnable", StringComparison.InvariantCultureIgnoreCase)) + { + return (int)await SetStartupState(true); + } + else if (argument.Equals("-StartupDisable", StringComparison.InvariantCultureIgnoreCase)) + { + return (int)await SetStartupState(false); + } + } + else + { + string path = GetAbsolutePath("ShareX.exe"); + Process.Start(path, "-silent"); + return 0; + } + } + catch + { + } + + return -1; + } + + private async static Task GetStartupState() + { + StartupTask startupTask = await StartupTask.GetAsync(TaskID); + return startupTask.State; + } + + private async static Task SetStartupState(bool enable) + { + StartupTask startupTask = await StartupTask.GetAsync(TaskID); + + if (enable) + { + return await startupTask.RequestEnableAsync(); + } + else + { + startupTask.Disable(); + return StartupTaskState.Disabled; + } + } + + private static string GetAbsolutePath(string path) + { + if (!Path.IsPathRooted(path)) // Is relative path? + { + path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); + } + + return Path.GetFullPath(path); + } + } +} \ No newline at end of file diff --git a/ShareX.DesktopBridgeHelper/Properties/AssemblyInfo.cs b/ShareX.DesktopBridgeHelper/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..a9b76002b --- /dev/null +++ b/ShareX.DesktopBridgeHelper/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ShareX DesktopBridgeHelper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("ShareX Team")] +[assembly: AssemblyProduct("ShareX")] +[assembly: AssemblyCopyright("Copyright (c) 2007-2017 ShareX Team")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2bf9aebb-b104-4b72-8298-04ca6d23b0e0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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")] diff --git a/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj b/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj new file mode 100644 index 000000000..f051b0dc5 --- /dev/null +++ b/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {2BF9AEBB-B104-4B72-8298-04CA6D23B0E0} + WinExe + ShareX.DesktopBridgeHelper + ShareX_DesktopBridgeHelper + v4.6.1 + 512 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + False + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll + + + False + C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD + + + C:\Program Files (x86)\Windows Kits\10\References\10.0.15063.0\Windows.ApplicationModel.StartupTaskContract\1.0.0.0\Windows.ApplicationModel.StartupTaskContract.winmd + + + C:\Program Files (x86)\Windows Kits\10\References\10.0.15063.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd + + + + + + + + + + + \ No newline at end of file diff --git a/ShareX.Setup/Program.cs b/ShareX.Setup/Program.cs index 85605deb1..1f78ebdd8 100644 --- a/ShareX.Setup/Program.cs +++ b/ShareX.Setup/Program.cs @@ -49,8 +49,8 @@ private enum SetupJobs Setup = CreateSetup | OpenOutputDirectory, Portable = CreatePortable | OpenOutputDirectory, Steam = CreateSteamFolder | OpenOutputDirectory, - WindowsStore = CreateWindowsStoreFolder | OpenOutputDirectory, - WindowsStoreDebug = CreateWindowsStoreDebugFolder | OpenOutputDirectory, + WindowsStore = CreateWindowsStoreFolder, + WindowsStoreDebug = CreateWindowsStoreDebugFolder, PortableApps = CreatePortableAppsFolder | OpenOutputDirectory, Beta = CreateSetup | UploadOutputFile, AppVeyorRelease = CreateSetup | CreatePortable, @@ -82,6 +82,7 @@ private enum SetupJobs private static string SteamLauncherDir => Path.Combine(ParentDir, @"ShareX.Steam\bin\Release"); private static string SteamUpdatesDir => Path.Combine(SteamOutputDir, "Updates"); private static string NativeMessagingHostDir => Path.Combine(ParentDir, @"ShareX.NativeMessagingHost\bin\Release"); + private static string DesktopBridgeHelperDir => Path.Combine(ParentDir, @"ShareX.DesktopBridgeHelper\bin\Release"); private static string RecorderDevicesSetupPath => Path.Combine(OutputDir, "Recorder-devices-setup.exe"); public static string InnoSetupCompilerPath = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe"; @@ -264,6 +265,7 @@ private static void CreateFolder(string source, string destination, SetupJobs jo } else if (job == SetupJobs.CreateWindowsStoreFolder || job == SetupJobs.CreateWindowsStoreDebugFolder) { + Helpers.CopyFile(Path.Combine(DesktopBridgeHelperDir, "ShareX_DesktopBridgeHelper.exe"), destination); Helpers.CopyAll(WindowsStorePackageFilesDir, destination); } else if (job == SetupJobs.CreatePortable) diff --git a/ShareX.Setup/ShareX.Setup.csproj b/ShareX.Setup/ShareX.Setup.csproj index 37bbf85ea..d73043f85 100644 --- a/ShareX.Setup/ShareX.Setup.csproj +++ b/ShareX.Setup/ShareX.Setup.csproj @@ -75,6 +75,9 @@ + + +