code cleanup

This commit is contained in:
Kang Yu 2024-05-10 14:46:59 -07:00
parent c41ab850bc
commit 30d2efad08
2 changed files with 4 additions and 10 deletions

View file

@ -19,7 +19,6 @@ namespace PersistentWindows.Common
{
private uint hotkey;
public static IntPtr parentHandle = IntPtr.Zero;
public static IntPtr handle = IntPtr.Zero;
private static System.Timers.Timer aliveTimer;
@ -543,23 +542,20 @@ namespace PersistentWindows.Common
}
}
public void HotKeyPressed(IntPtr parent_handle, bool from_menu)
public void HotKeyPressed(bool from_menu)
{
if (InvokeRequired)
BeginInvoke((Action) delegate ()
{
HotKeyPressed(parent_handle, from_menu);
HotKeyPressed(from_menu);
});
else
{
parentHandle = parent_handle;
if (!from_menu)
{
IntPtr fgwnd = GetForegroundWindow();
if (!IsBrowserWindow(fgwnd))
{
//User32.UnregisterHotKey(parentHandle, 0);
//forward hotkey
char c = Convert.ToChar(hotkey);
string cmd = $"%{c}";

View file

@ -10,7 +10,6 @@ namespace PersistentWindows.SystrayShell
public class HotKeyForm : Form
{
static HotKeyWindow hkwin = null;
static IntPtr handle;
static Thread messageLoop;
public static void Start(uint hotkey)
@ -32,7 +31,6 @@ namespace PersistentWindows.SystrayShell
{
//InitializeComponent();
var r = User32.RegisterHotKey(this.Handle, 0, (int)User32.KeyModifier.Alt, hotkey); // Register Alt + W
handle = this.Handle;
}
protected override void WndProc(ref Message m)
@ -50,7 +48,7 @@ namespace PersistentWindows.SystrayShell
Program.HideRestoreTip(false); //hide icon
Program.HideRestoreTip(); //show icon
hkwin.HotKeyPressed(this.Handle, from_menu : false);
hkwin.HotKeyPressed(from_menu : false);
return;
}
else if (m.Msg == 0x0010 || m.Msg == 0x0002)
@ -65,7 +63,7 @@ namespace PersistentWindows.SystrayShell
{
Program.HideRestoreTip(false); //hide icon
Program.HideRestoreTip(); //show icon
hkwin.HotKeyPressed(handle, from_menu: true);
hkwin.HotKeyPressed(from_menu: true);
}
protected override void SetVisibleCore(bool value)