Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse click effect capability for screen recording #7622

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
implement right click effect
  • Loading branch information
Vertygo committed Oct 13, 2024
commit 582d793170b0bf1633f439f44a656396283f7ffe
9 changes: 6 additions & 3 deletions ShareX.HelpersLib/Input/MouseClickEffectForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ protected override CreateParams CreateParams
/// <summary>
/// Draw mouse effect on given mouse position
/// </summary>
public void DrawMouseEffect(Point cursorPosition)
public void DrawMouseEffect(MouseEventInfo eventInfo)
{
CenterFormToCursorPosition(cursorPosition);
SelectBitmap(GetCircleImage(Color.Red), 100);
// color will come from customizable color setting when implemented
var color = eventInfo.ButtonState == ButtonState.LeftButtonDown ? Color.Red : Color.Blue;

CenterFormToCursorPosition(eventInfo.CursorPosition);
SelectBitmap(GetCircleImage(color), 100);
}

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion ShareX.HelpersLib/Input/MouseClickEffectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ private void OnMouseEvent(MouseEventInfo eventInfo)
switch (eventInfo.ButtonState)
{
case ButtonState.LeftButtonDown:
clickEffectForm.DrawMouseEffect(eventInfo.CursorPosition);
clickEffectForm.DrawMouseEffect(eventInfo);
break;
case ButtonState.RightButtonDown:
clickEffectForm.DrawMouseEffect(eventInfo);
break;
default:
clickEffectForm.ClearMouseEffect();
Expand Down
15 changes: 14 additions & 1 deletion ShareX.HelpersLib/Input/MouseHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,27 @@ private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
CursorPosition = CaptureHelpers.GetCursorPosition()
});
break;

case WindowsMessages.RBUTTONDOWN:
OnMouseEvent(new MouseEventInfo
{
ButtonState = ButtonState.RightButtonDown,
CursorPosition = CaptureHelpers.GetCursorPosition()
});
break;
case WindowsMessages.LBUTTONUP:
OnMouseEvent(new MouseEventInfo
{
ButtonState = ButtonState.ButtonUp,
CursorPosition = CaptureHelpers.GetCursorPosition()
});
break;
case WindowsMessages.RBUTTONUP:
OnMouseEvent(new MouseEventInfo
{
ButtonState = ButtonState.ButtonUp,
CursorPosition = CaptureHelpers.GetCursorPosition()
});
break;
}
}

Expand Down