mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
Add start Wox on system startup config & code refactorying.
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
@@ -13,6 +20,11 @@ namespace Wox
|
||||
{
|
||||
private MainWindow mainWindow;
|
||||
|
||||
public SettingWidow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public SettingWidow(MainWindow mainWindow)
|
||||
{
|
||||
this.mainWindow = mainWindow;
|
||||
@@ -98,5 +110,47 @@ namespace Wox
|
||||
MessageBox.Show("Please select a web search");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OnStartWithWindowsChecked();
|
||||
}
|
||||
|
||||
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OnStartWithWindowUnChecked();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void OnStartWithWindowUnChecked()
|
||||
{
|
||||
UAC.ExecuteAdminMethod(() => SetStartup(false));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void OnStartWithWindowsChecked()
|
||||
{
|
||||
UAC.ExecuteAdminMethod(() => SetStartup(true));
|
||||
}
|
||||
|
||||
private void SetStartup(bool startup)
|
||||
{
|
||||
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
||||
|
||||
if (rk != null)
|
||||
{
|
||||
if (startup)
|
||||
{
|
||||
rk.SetValue("Wox",Path.Combine(Directory.GetCurrentDirectory(),"Wox.exe startHide"));
|
||||
}
|
||||
else
|
||||
{
|
||||
rk.DeleteValue("Wox", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user