putting tiny hotkey at the left side of hand cursor, so that mouse click will be send to fgwindow directly

This commit is contained in:
Kang Yu 2024-03-27 16:57:28 -07:00
parent e354c2f2bf
commit 224ff0324f
2 changed files with 19 additions and 28 deletions

View file

@ -28,6 +28,7 @@ namespace PersistentWindows.Common
private int mouseOffset = 0; private int mouseOffset = 0;
private static POINT lastCursorPos; private static POINT lastCursorPos;
private Color dfltBackColor; private Color dfltBackColor;
private bool handCursor = false;
public HotKeyWindow() public HotKeyWindow()
{ {
@ -150,27 +151,12 @@ namespace PersistentWindows.Common
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
//page down //page down
if (BackColor == dfltBackColor) SendKeys.Send("{PGDN}");
SendKeys.Send("{PGDN}");
else
{
Visible = false;
//forward click
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP, 0, 0, 0, UIntPtr.Zero);
Visible = true;
}
} }
else if (e.Button == MouseButtons.Right) else if (e.Button == MouseButtons.Right)
{ {
//page up //page up
if (BackColor == dfltBackColor) SendKeys.Send("{PGUP}");
SendKeys.Send("{PGUP}");
else
{
Visible = false;
User32.mouse_event(MouseAction.MOUSEEVENTF_RIGHTDOWN | MouseAction.MOUSEEVENTF_RIGHTUP, 0, 0, 0, UIntPtr.Zero);
Visible = true;
}
} }
else if (e.Button == MouseButtons.Middle) else if (e.Button == MouseButtons.Middle)
{ {
@ -193,12 +179,7 @@ namespace PersistentWindows.Common
//Show(); //Show();
StartMouseScrollTimer(); StartMouseScrollTimer();
if (BackColor != dfltBackColor) StartAliveTimer();
{
Cursor = Cursors.Default;
BackColor = dfltBackColor;
StartAliveTimer();
}
} }
private void FormMouseLeave(object sender, EventArgs e) private void FormMouseLeave(object sender, EventArgs e)
@ -268,7 +249,7 @@ namespace PersistentWindows.Common
else else
{ {
SendKeys.Send("^t"); //new tab SendKeys.Send("^t"); //new tab
SendKeys.Send("^l"); SendKeys.Send("^l"); //focus in address bar
return_focus_to_hotkey_window = false; return_focus_to_hotkey_window = false;
if (tiny) if (tiny)
Visible = false; Visible = false;
@ -529,9 +510,12 @@ namespace PersistentWindows.Common
ResetHotKeyVirtualDesktop(); ResetHotKeyVirtualDesktop();
ResetHotkeyWindowPos(); ResetHotkeyWindowPos();
if (hCursor == Cursors.Default.Handle)
handCursor = false;
if (!Visible) if (!Visible)
Show(); Show();
else else if (!handCursor)
User32.SetForegroundWindow(Handle); User32.SetForegroundWindow(Handle);
if (hCursor == Cursors.Default.Handle) if (hCursor == Cursors.Default.Handle)
@ -539,13 +523,21 @@ namespace PersistentWindows.Common
//arrow cursor //arrow cursor
BackColor = dfltBackColor; BackColor = dfltBackColor;
Cursor = Cursors.Default; Cursor = Cursors.Default;
return;
} }
else
if (!handCursor)
{ {
BackColor = Color.Red; BackColor = Color.Red;
Cursor = new Cursor(hCursor); Cursor = new Cursor(hCursor);
Left -= 10;
handCursor = true;
}
else
{
Left -= 10;
} }
return;
} }
StartAliveTimer(); StartAliveTimer();

View file

@ -36,7 +36,6 @@ namespace PersistentWindows.SystrayShell
{ {
if (m.Msg == 0x0312) if (m.Msg == 0x0312)
{ {
/* Note that the three lines below are not needed if you only want to register one hotkey. /* Note that the three lines below are not needed if you only want to register one hotkey.
* The below lines are useful in case you want to register multiple keys, which you can use a switch with the id as argument, or if you want to know which key/modifier was pressed for some particular reason. */ * The below lines are useful in case you want to register multiple keys, which you can use a switch with the id as argument, or if you want to know which key/modifier was pressed for some particular reason. */