mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-02 10:34:42 +12:00
[BUG] Microsoft Store Autostart not working (#131), version 1.0.22.2
This commit is contained in:
parent
15cf58c28c
commit
8cff4365fc
|
@ -3,6 +3,7 @@
|
||||||
<Package
|
<Package
|
||||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
|
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
|
||||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||||
IgnorableNamespaces="uap rescap">
|
IgnorableNamespaces="uap rescap">
|
||||||
|
|
||||||
|
@ -40,6 +41,15 @@
|
||||||
<uap:SplashScreen Image="Images\SplashScreen.png" />
|
<uap:SplashScreen Image="Images\SplashScreen.png" />
|
||||||
<uap:LockScreen BadgeLogo="Images\BadgeLogo.png" Notification="badge"/>
|
<uap:LockScreen BadgeLogo="Images\BadgeLogo.png" Notification="badge"/>
|
||||||
</uap:VisualElements>
|
</uap:VisualElements>
|
||||||
|
<Extensions>
|
||||||
|
<uap5:Extension
|
||||||
|
Category="windows.startupTask">
|
||||||
|
<uap5:StartupTask
|
||||||
|
TaskId="MyStartupId"
|
||||||
|
Enabled="false"
|
||||||
|
DisplayName="SystemTrayMenu" />
|
||||||
|
</uap5:Extension>
|
||||||
|
</Extensions>
|
||||||
</Application>
|
</Application>
|
||||||
</Applications>
|
</Applications>
|
||||||
|
|
||||||
|
|
|
@ -286,11 +286,12 @@
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22000.194" />
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Svg" Version="3.2.3" />
|
<PackageReference Include="Svg" Version="3.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Packaging\AppPackages\" />
|
<Folder Include="Packaging\AppPackages\" />
|
||||||
|
|
|
@ -10,10 +10,12 @@ namespace SystemTrayMenu.UserInterface
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using SystemTrayMenu.Properties;
|
using SystemTrayMenu.Properties;
|
||||||
using SystemTrayMenu.Utilities;
|
using SystemTrayMenu.Utilities;
|
||||||
|
using Windows.ApplicationModel;
|
||||||
using static SystemTrayMenu.UserInterface.HotkeyTextboxControl.HotkeyControl;
|
using static SystemTrayMenu.UserInterface.HotkeyTextboxControl.HotkeyControl;
|
||||||
|
|
||||||
public partial class SettingsForm : Form
|
public partial class SettingsForm : Form
|
||||||
|
@ -203,6 +205,12 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
checkBoxAutostart.Checked =
|
checkBoxAutostart.Checked =
|
||||||
Settings.Default.IsAutostartActivated;
|
Settings.Default.IsAutostartActivated;
|
||||||
|
#if RELEASEPACKAGE
|
||||||
|
if (Settings.Default.IsAutostartActivated)
|
||||||
|
{
|
||||||
|
checkBoxAutostart.Enabled = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeHotkey();
|
InitializeHotkey();
|
||||||
|
@ -563,23 +571,64 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Settings.Default.UseIconFromRootFolder =
|
Settings.Default.UseIconFromRootFolder =
|
||||||
checkBoxUseIconFromRootFolder.Checked;
|
checkBoxUseIconFromRootFolder.Checked;
|
||||||
|
|
||||||
SaveAutostart();
|
_ = SaveAutostartAsync().Wait(8000);
|
||||||
void SaveAutostart()
|
async Task SaveAutostartAsync()
|
||||||
{
|
{
|
||||||
|
bool useStartupTask = false;
|
||||||
|
#if RELEASEPACKAGE
|
||||||
|
useStartupTask = true;
|
||||||
|
#endif
|
||||||
if (checkBoxAutostart.Checked)
|
if (checkBoxAutostart.Checked)
|
||||||
{
|
{
|
||||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(
|
if (useStartupTask)
|
||||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
{
|
||||||
key.SetValue(
|
// Pass the task ID you specified in the appxmanifest file
|
||||||
Assembly.GetExecutingAssembly().GetName().Name,
|
StartupTask startupTask = await StartupTask.GetAsync("MyStartupId");
|
||||||
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
|
Log.Info($"Autostart {startupTask.State}.");
|
||||||
|
|
||||||
|
switch (startupTask.State)
|
||||||
|
{
|
||||||
|
case StartupTaskState.Enabled:
|
||||||
|
break;
|
||||||
|
case StartupTaskState.Disabled:
|
||||||
|
// Task is disabled but can be enabled.
|
||||||
|
StartupTaskState newState = await startupTask.RequestEnableAsync();
|
||||||
|
break;
|
||||||
|
case StartupTaskState.DisabledByUser:
|
||||||
|
Log.Info($"Please enable autostart via Task Manager.");
|
||||||
|
break;
|
||||||
|
case StartupTaskState.DisabledByPolicy:
|
||||||
|
Log.Info($"Autostart disabled by policy. Please add autostart manually, see issue #131");
|
||||||
|
break;
|
||||||
|
case StartupTaskState.EnabledByPolicy:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RegistryKey key = Registry.CurrentUser.OpenSubKey(
|
||||||
|
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
||||||
|
key.SetValue(
|
||||||
|
Assembly.GetExecutingAssembly().GetName().Name,
|
||||||
|
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
Settings.Default.IsAutostartActivated = true;
|
Settings.Default.IsAutostartActivated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(
|
if (useStartupTask)
|
||||||
|
{
|
||||||
|
// when added by StartupTask, then only possible to disable autostart via Task Manager.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RegistryKey key = Registry.CurrentUser.OpenSubKey(
|
||||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
||||||
key.DeleteValue("SystemTrayMenu", false);
|
key.DeleteValue("SystemTrayMenu", false);
|
||||||
|
}
|
||||||
|
|
||||||
Settings.Default.IsAutostartActivated = false;
|
Settings.Default.IsAutostartActivated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue