Skip to content

Add missing double click extension methods and enhance mouse input APIs #279

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 13, 2025

This PR enhances the double click APIs by adding missing extension methods and ensuring proper accessibility of the double click timing property.

Changes Made

New Extension Methods Added

  • RightDoubleClick() - Performs right mouse button double click
  • MiddleClick() - Performs middle mouse button single click
  • MiddleDoubleClick() - Performs middle mouse button double click

All new methods follow the same consistent API pattern as existing methods:

await element.RightDoubleClick(Position.Center, xOffset: 10, yOffset: 5);
await element.MiddleClick();
await element.MiddleDoubleClick(clickTime: TimeSpan.FromMilliseconds(200));

Enhanced Test Coverage

Added comprehensive tests for all new methods:

  • CanRightDoubleClickOnButton()
  • CanMiddleClickOnButton()
  • CanMiddleDoubleClickOnButton()
  • DoubleClickTimeIsAccessibleWithoutWinForms() - Verifies the double click timing property works without WinForms dependency

Requirements Fulfilled

Extension methods for double click - Now all mouse buttons support both single and double click operations (Left, Right, Middle)

Double click timing without WinForms - The MouseInput.GetDoubleClickTime property was already properly implemented using Windows API directly:

public static TimeSpan GetDoubleClickTime 
    => TimeSpan.FromMilliseconds(Windows.Win32.PInvoke.GetDoubleClickTime());

This avoids the WinForms dependency that would come from SystemInformation.DoubleClickTime.

API Consistency

The implementation maintains full consistency with existing patterns:

  • Same method signatures and parameter names
  • Same async/await patterns
  • Same return types (Task<Point>)
  • Same position and offset support
  • Same optional click timing support

Fixes #192.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI assigned Copilot and Keboo Jun 13, 2025
@Copilot Copilot AI changed the title [WIP] Better double click APIs Add missing double click extension methods and enhance mouse input APIs Jun 13, 2025
@Copilot Copilot AI requested a review from Keboo June 13, 2025 04:09
{
// Verify that GetDoubleClickTime works without needing WinForms reference
TimeSpan doubleClickTime = MouseInput.GetDoubleClickTime;
Assert.IsTrue(doubleClickTime.TotalMilliseconds > 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Assert.IsTrue(doubleClickTime.TotalMilliseconds > 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better double click APIs
1 participant