mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 13:05:38 +02:00
#331, Ctrl + Win + Toggle Webpage Commander to unregister hotkey
This commit is contained in:
parent
2c31ed0002
commit
a0fc8711f8
2 changed files with 23 additions and 3 deletions
|
@ -4,6 +4,7 @@ using System.Windows.Forms;
|
|||
|
||||
using PersistentWindows.Common;
|
||||
using PersistentWindows.Common.WinApiBridge;
|
||||
using PersistentWindows.Common.Diagnostics;
|
||||
|
||||
namespace PersistentWindows.SystrayShell
|
||||
{
|
||||
|
@ -11,13 +12,15 @@ namespace PersistentWindows.SystrayShell
|
|||
{
|
||||
static HotKeyWindow hkwin = null;
|
||||
static Thread messageLoop;
|
||||
static HotKeyForm hkf = null;
|
||||
|
||||
public static void Start(uint hotkey)
|
||||
{
|
||||
messageLoop = new Thread(() =>
|
||||
{
|
||||
hkwin = new HotKeyWindow(hotkey);
|
||||
Application.Run(new HotKeyForm(hotkey));
|
||||
hkf = new HotKeyForm(hotkey);
|
||||
Application.Run(hkf);
|
||||
})
|
||||
{
|
||||
Name = "MessageLoopThread",
|
||||
|
@ -27,6 +30,12 @@ namespace PersistentWindows.SystrayShell
|
|||
messageLoop.Start();
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
if (messageLoop.IsAlive)
|
||||
messageLoop.Abort();
|
||||
}
|
||||
|
||||
public HotKeyForm(uint hotkey)
|
||||
{
|
||||
//InitializeComponent();
|
||||
|
@ -54,6 +63,7 @@ namespace PersistentWindows.SystrayShell
|
|||
else if (m.Msg == 0x0010 || m.Msg == 0x0002)
|
||||
{
|
||||
r = User32.UnregisterHotKey(this.Handle, 0);
|
||||
Log.Event($"unregister hotkey {r}");
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
|
@ -65,7 +75,7 @@ namespace PersistentWindows.SystrayShell
|
|||
Program.HideRestoreTip(); //show icon
|
||||
hkwin.HotKeyPressed(from_menu: true);
|
||||
}
|
||||
|
||||
|
||||
protected override void SetVisibleCore(bool value)
|
||||
{
|
||||
// Ensure the window never becomes visible
|
||||
|
|
|
@ -343,7 +343,17 @@ namespace PersistentWindows.SystrayShell
|
|||
|
||||
private void WebCommander(object sender, EventArgs e)
|
||||
{
|
||||
HotKeyForm.InvokeFromMenu();
|
||||
if ((User32.GetKeyState(0x5b) & 0x8000) != 0 //left window logo key pressed
|
||||
&& (User32.GetKeyState(0x11) & 0x8000) != 0) //ctrl key pressed
|
||||
{
|
||||
//this.invokeWebCommander.Enabled = false;
|
||||
this.invokeWebCommander.Visible = false;
|
||||
HotKeyForm.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
HotKeyForm.InvokeFromMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleIcon(object sender, EventArgs e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue