From 6edf1068e02f3d5ed0210f836d3fa367842b579f Mon Sep 17 00:00:00 2001 From: Julius Date: Wed, 8 Apr 2015 20:13:59 +0100 Subject: [PATCH 1/3] Expose middle button down, up, click, double click on MouseSimulator --- WindowsInput/IMouseSimulator.cs | 20 +++++++++++++ WindowsInput/MouseSimulator.cs | 40 +++++++++++++++++++++++++ WindowsInput/Properties/AssemblyInfo.cs | 4 +-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/WindowsInput/IMouseSimulator.cs b/WindowsInput/IMouseSimulator.cs index 7cce7b7..4397924 100644 --- a/WindowsInput/IMouseSimulator.cs +++ b/WindowsInput/IMouseSimulator.cs @@ -54,6 +54,26 @@ public interface IMouseSimulator /// IMouseSimulator LeftButtonDoubleClick(); + /// + /// Simulates a mouse Middle button down gesture. + /// + IMouseSimulator MiddleButtonDown(); + + /// + /// Simulates a mouse Middle button up gesture. + /// + IMouseSimulator MiddleButtonUp(); + + /// + /// Simulates a mouse Middle button click gesture. + /// + IMouseSimulator MiddleButtonClick(); + + /// + /// Simulates a mouse Middle button double-click gesture. + /// + IMouseSimulator MiddleButtonDoubleClick(); + /// /// Simulates a mouse right button down gesture. /// diff --git a/WindowsInput/MouseSimulator.cs b/WindowsInput/MouseSimulator.cs index 9873076..0af419c 100644 --- a/WindowsInput/MouseSimulator.cs +++ b/WindowsInput/MouseSimulator.cs @@ -141,6 +141,46 @@ public IMouseSimulator LeftButtonDoubleClick() return this; } + /// + /// Simulates a mouse Middle button down gesture. + /// + public IMouseSimulator MiddleButtonDown() + { + var inputList = new InputBuilder().AddMouseButtonDown(MouseButton.MiddleButton).ToArray(); + SendSimulatedInput(inputList); + return this; + } + + /// + /// Simulates a mouse Middle button up gesture. + /// + public IMouseSimulator MiddleButtonUp() + { + var inputList = new InputBuilder().AddMouseButtonUp(MouseButton.MiddleButton).ToArray(); + SendSimulatedInput(inputList); + return this; + } + + /// + /// Simulates a mouse Middle-click gesture. + /// + public IMouseSimulator MiddleButtonClick() + { + var inputList = new InputBuilder().AddMouseButtonClick(MouseButton.MiddleButton).ToArray(); + SendSimulatedInput(inputList); + return this; + } + + /// + /// Simulates a mouse Middle button double-click gesture. + /// + public IMouseSimulator MiddleButtonDoubleClick() + { + var inputList = new InputBuilder().AddMouseButtonDoubleClick(MouseButton.MiddleButton).ToArray(); + SendSimulatedInput(inputList); + return this; + } + /// /// Simulates a mouse right button down gesture. /// diff --git a/WindowsInput/Properties/AssemblyInfo.cs b/WindowsInput/Properties/AssemblyInfo.cs index 4871bf0..2b938ea 100644 --- a/WindowsInput/Properties/AssemblyInfo.cs +++ b/WindowsInput/Properties/AssemblyInfo.cs @@ -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")] From 8b20805aa11f4ffa25cbe80d83cee33bae9f1aa6 Mon Sep 17 00:00:00 2001 From: Julius Date: Wed, 8 Apr 2015 20:16:16 +0100 Subject: [PATCH 2/3] Corrected casing on method summaries --- WindowsInput/IMouseSimulator.cs | 8 ++++---- WindowsInput/MouseSimulator.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WindowsInput/IMouseSimulator.cs b/WindowsInput/IMouseSimulator.cs index 4397924..e890399 100644 --- a/WindowsInput/IMouseSimulator.cs +++ b/WindowsInput/IMouseSimulator.cs @@ -55,22 +55,22 @@ public interface IMouseSimulator IMouseSimulator LeftButtonDoubleClick(); /// - /// Simulates a mouse Middle button down gesture. + /// Simulates a mouse middle button down gesture. /// IMouseSimulator MiddleButtonDown(); /// - /// Simulates a mouse Middle button up gesture. + /// Simulates a mouse middle button up gesture. /// IMouseSimulator MiddleButtonUp(); /// - /// Simulates a mouse Middle button click gesture. + /// Simulates a mouse middle button click gesture. /// IMouseSimulator MiddleButtonClick(); /// - /// Simulates a mouse Middle button double-click gesture. + /// Simulates a mouse middle button double-click gesture. /// IMouseSimulator MiddleButtonDoubleClick(); diff --git a/WindowsInput/MouseSimulator.cs b/WindowsInput/MouseSimulator.cs index 0af419c..8f7f64f 100644 --- a/WindowsInput/MouseSimulator.cs +++ b/WindowsInput/MouseSimulator.cs @@ -142,7 +142,7 @@ public IMouseSimulator LeftButtonDoubleClick() } /// - /// Simulates a mouse Middle button down gesture. + /// Simulates a mouse middle button down gesture. /// public IMouseSimulator MiddleButtonDown() { @@ -152,7 +152,7 @@ public IMouseSimulator MiddleButtonDown() } /// - /// Simulates a mouse Middle button up gesture. + /// Simulates a mouse middle button up gesture. /// public IMouseSimulator MiddleButtonUp() { @@ -162,7 +162,7 @@ public IMouseSimulator MiddleButtonUp() } /// - /// Simulates a mouse Middle-click gesture. + /// Simulates a mouse middle-click gesture. /// public IMouseSimulator MiddleButtonClick() { @@ -172,7 +172,7 @@ public IMouseSimulator MiddleButtonClick() } /// - /// Simulates a mouse Middle button double-click gesture. + /// Simulates a mouse middle button double-click gesture. /// public IMouseSimulator MiddleButtonDoubleClick() { From ebd50efcb3daf1e832bee68443264b6cc14fa6e8 Mon Sep 17 00:00:00 2001 From: Joshua Campbell Date: Wed, 10 Jan 2018 13:14:20 -0500 Subject: [PATCH 3/3] Add absolute vertical/horizontal scroll methods For higher resolution scrolling in apps that support it, without being limited to only whole "clicks" of the mouse wheel --- WindowsInput/IMouseSimulator.cs | 12 ++++++++++++ WindowsInput/MouseSimulator.cs | 22 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/WindowsInput/IMouseSimulator.cs b/WindowsInput/IMouseSimulator.cs index e890399..8e98404 100644 --- a/WindowsInput/IMouseSimulator.cs +++ b/WindowsInput/IMouseSimulator.cs @@ -124,12 +124,24 @@ public interface IMouseSimulator /// 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. IMouseSimulator VerticalScroll(int scrollAmountInClicks); + /// + /// Simulates mouse vertical wheel scroll gesture. + /// + /// 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. + IMouseSimulator VerticalScrollAbsolute(int scrollAmount); + /// /// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later. /// /// 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. IMouseSimulator HorizontalScroll(int scrollAmountInClicks); + /// + /// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later. + /// + /// 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. + IMouseSimulator HorizontalScrollAbsolute(int scrollAmount); + /// /// Sleeps the executing thread to create a pause between simulated inputs. /// diff --git a/WindowsInput/MouseSimulator.cs b/WindowsInput/MouseSimulator.cs index 8f7f64f..a7f209c 100644 --- a/WindowsInput/MouseSimulator.cs +++ b/WindowsInput/MouseSimulator.cs @@ -271,7 +271,16 @@ public IMouseSimulator XButtonDoubleClick(int buttonId) /// 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. public IMouseSimulator VerticalScroll(int scrollAmountInClicks) { - var inputList = new InputBuilder().AddMouseVerticalWheelScroll(scrollAmountInClicks * MouseWheelClickSize).ToArray(); + return VerticalScrollAbsolute(scrollAmountInClicks * MouseWheelClickSize); + } + + /// + /// Simulates mouse vertical wheel scroll gesture. + /// + /// 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. + public IMouseSimulator VerticalScrollAbsolute(int scrollAmount) + { + var inputList = new InputBuilder().AddMouseVerticalWheelScroll(scrollAmount).ToArray(); SendSimulatedInput(inputList); return this; } @@ -282,7 +291,16 @@ public IMouseSimulator VerticalScroll(int 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. public IMouseSimulator HorizontalScroll(int scrollAmountInClicks) { - var inputList = new InputBuilder().AddMouseHorizontalWheelScroll(scrollAmountInClicks * MouseWheelClickSize).ToArray(); + return HorizontalScrollAbsolute(scrollAmountInClicks * MouseWheelClickSize); + } + + /// + /// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later. + /// + /// 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. + public IMouseSimulator HorizontalScrollAbsolute(int scrollAmount) + { + var inputList = new InputBuilder().AddMouseHorizontalWheelScroll(scrollAmount).ToArray(); SendSimulatedInput(inputList); return this; }