add command option -hotkey to allow customization, such as -hotkey "Q", change default hotkey to (Alt+)W

This commit is contained in:
Kang Yu 2024-04-13 15:05:30 -07:00
parent 307963f851
commit 466517da1e
3 changed files with 32 additions and 17 deletions

View file

@ -11,12 +11,12 @@ namespace PersistentWindows.SystrayShell
{
static HotKeyWindow hkwin = null;
public static void Start()
public static void Start(uint hotkey)
{
Thread messageLoop = new Thread(() =>
{
hkwin = new HotKeyWindow();
Application.Run(new HotKeyForm());
hkwin = new HotKeyWindow(hotkey);
Application.Run(new HotKeyForm(hotkey));
})
{
Name = "MessageLoopThread",
@ -26,10 +26,10 @@ namespace PersistentWindows.SystrayShell
messageLoop.Start();
}
public HotKeyForm()
public HotKeyForm(uint hotkey)
{
//InitializeComponent();
var r = User32.RegisterHotKey(this.Handle, 0, (int)User32.KeyModifier.Alt, 0x51); // Register Alt + Q
var r = User32.RegisterHotKey(this.Handle, 0, (int)User32.KeyModifier.Alt, hotkey); // Register Alt + W
}
protected override void WndProc(ref Message m)