#308, Alt + Close hotkey window to deactivate hotkey feature (in current PW process)

This commit is contained in:
Kang Yu 2024-04-09 13:09:31 -07:00
parent 94730bf324
commit 0b7661a30e
2 changed files with 13 additions and 9 deletions

View file

@ -17,6 +17,7 @@ namespace PersistentWindows.Common
{
public partial class HotKeyWindow : Form
{
public static IntPtr parentHandle = IntPtr.Zero;
public static IntPtr handle = IntPtr.Zero;
private static System.Timers.Timer aliveTimer;
@ -165,6 +166,13 @@ namespace PersistentWindows.Common
});
else
{
bool alt_key_pressed = (User32.GetKeyState(0x12) & 0x8000) != 0;
if (alt_key_pressed)
{
User32.UnregisterHotKey(parentHandle, 0);
return;
}
e.Cancel = true;
if (User32.IsWindow(Handle))
{
@ -467,21 +475,17 @@ namespace PersistentWindows.Common
}
}
void FormKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
}
public void HotKeyPressed()
public void HotKeyPressed(IntPtr parent_handle)
{
if (InvokeRequired)
BeginInvoke((Action) delegate ()
{
HotKeyPressed();
HotKeyPressed(parent_handle);
});
else
{
parentHandle = parent_handle;
if (!active)
{
if (init)

View file

@ -45,7 +45,7 @@ namespace PersistentWindows.SystrayShell
Program.HideRestoreTip(false); //hide icon
Program.HideRestoreTip(); //show icon
hkwin.HotKeyPressed();
hkwin.HotKeyPressed(this.Handle);
return;
}