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

View file

@ -36,7 +36,6 @@ namespace PersistentWindows.SystrayShell
{
if (m.Msg == 0x0312)
{
/* 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. */