mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 13:05:38 +02:00
#308, Alt + Close hotkey window to deactivate hotkey feature (in current PW process)
This commit is contained in:
parent
94730bf324
commit
0b7661a30e
2 changed files with 13 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace PersistentWindows.SystrayShell
|
|||
|
||||
Program.HideRestoreTip(false); //hide icon
|
||||
Program.HideRestoreTip(); //show icon
|
||||
hkwin.HotKeyPressed();
|
||||
hkwin.HotKeyPressed(this.Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue