Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions WindowsInput/IMouseSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ public interface IMouseSimulator
/// </summary>
IMouseSimulator LeftButtonDoubleClick();

/// <summary>
/// Simulates a mouse middle button down gesture.
/// </summary>
IMouseSimulator MiddleButtonDown();

/// <summary>
/// Simulates a mouse middle button up gesture.
/// </summary>
IMouseSimulator MiddleButtonUp();

/// <summary>
/// Simulates a mouse middle button click gesture.
/// </summary>
IMouseSimulator MiddleButtonClick();

/// <summary>
/// Simulates a mouse middle button double-click gesture.
/// </summary>
IMouseSimulator MiddleButtonDoubleClick();

/// <summary>
/// Simulates a mouse right button down gesture.
/// </summary>
Expand Down Expand Up @@ -104,12 +124,24 @@ public interface IMouseSimulator
/// <param name="scrollAmountInClicks">The amount to scroll in clicks. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.</param>
IMouseSimulator VerticalScroll(int scrollAmountInClicks);

/// <summary>
/// Simulates mouse vertical wheel scroll gesture.
/// </summary>
/// <param name="scrollAmount">The absolute amount to scroll. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.</param>
IMouseSimulator VerticalScrollAbsolute(int scrollAmount);

/// <summary>
/// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later.
/// </summary>
/// <param name="scrollAmountInClicks">The amount to scroll in clicks. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.</param>
IMouseSimulator HorizontalScroll(int scrollAmountInClicks);

/// <summary>
/// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later.
/// </summary>
/// <param name="scrollAmount">The absolute amount to scroll. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.</param>
IMouseSimulator HorizontalScrollAbsolute(int scrollAmount);

/// <summary>
/// Sleeps the executing thread to create a pause between simulated inputs.
/// </summary>
Expand Down
62 changes: 60 additions & 2 deletions WindowsInput/MouseSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,46 @@ public IMouseSimulator LeftButtonDoubleClick()
return this;
}

/// <summary>
/// Simulates a mouse middle button down gesture.
/// </summary>
public IMouseSimulator MiddleButtonDown()
{
var inputList = new InputBuilder().AddMouseButtonDown(MouseButton.MiddleButton).ToArray();
SendSimulatedInput(inputList);
return this;
}

/// <summary>
/// Simulates a mouse middle button up gesture.
/// </summary>
public IMouseSimulator MiddleButtonUp()
{
var inputList = new InputBuilder().AddMouseButtonUp(MouseButton.MiddleButton).ToArray();
SendSimulatedInput(inputList);
return this;
}

/// <summary>
/// Simulates a mouse middle-click gesture.
/// </summary>
public IMouseSimulator MiddleButtonClick()
{
var inputList = new InputBuilder().AddMouseButtonClick(MouseButton.MiddleButton).ToArray();
SendSimulatedInput(inputList);
return this;
}

/// <summary>
/// Simulates a mouse middle button double-click gesture.
/// </summary>
public IMouseSimulator MiddleButtonDoubleClick()
{
var inputList = new InputBuilder().AddMouseButtonDoubleClick(MouseButton.MiddleButton).ToArray();
SendSimulatedInput(inputList);
return this;
}

/// <summary>
/// Simulates a mouse right button down gesture.
/// </summary>
Expand Down Expand Up @@ -231,7 +271,16 @@ public IMouseSimulator XButtonDoubleClick(int buttonId)
/// <param name="scrollAmountInClicks">The amount to scroll in clicks. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.</param>
public IMouseSimulator VerticalScroll(int scrollAmountInClicks)
{
var inputList = new InputBuilder().AddMouseVerticalWheelScroll(scrollAmountInClicks * MouseWheelClickSize).ToArray();
return VerticalScrollAbsolute(scrollAmountInClicks * MouseWheelClickSize);
}

/// <summary>
/// Simulates mouse vertical wheel scroll gesture.
/// </summary>
/// <param name="scrollAmount">The absolute amount to scroll. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.</param>
public IMouseSimulator VerticalScrollAbsolute(int scrollAmount)
{
var inputList = new InputBuilder().AddMouseVerticalWheelScroll(scrollAmount).ToArray();
SendSimulatedInput(inputList);
return this;
}
Expand All @@ -242,7 +291,16 @@ public IMouseSimulator VerticalScroll(int scrollAmountInClicks)
/// <param name="scrollAmountInClicks">The amount to scroll in clicks. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.</param>
public IMouseSimulator HorizontalScroll(int scrollAmountInClicks)
{
var inputList = new InputBuilder().AddMouseHorizontalWheelScroll(scrollAmountInClicks * MouseWheelClickSize).ToArray();
return HorizontalScrollAbsolute(scrollAmountInClicks * MouseWheelClickSize);
}

/// <summary>
/// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later.
/// </summary>
/// <param name="scrollAmount">The absolute amount to scroll. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.</param>
public IMouseSimulator HorizontalScrollAbsolute(int scrollAmount)
{
var inputList = new InputBuilder().AddMouseHorizontalWheelScroll(scrollAmount).ToArray();
SendSimulatedInput(inputList);
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions WindowsInput/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("1.0.4.1")]
[assembly: AssemblyFileVersion("1.0.4.1")]