MouseHook 1.0.6
dotnet add package MouseHook --version 1.0.6
NuGet\Install-Package MouseHook -Version 1.0.6
<PackageReference Include="MouseHook" Version="1.0.6" />
<PackageVersion Include="MouseHook" Version="1.0.6" />
<PackageReference Include="MouseHook" />
paket add MouseHook --version 1.0.6
#r "nuget: MouseHook, 1.0.6"
#:package MouseHook@1.0.6
#addin nuget:?package=MouseHook&version=1.0.6
#tool nuget:?package=MouseHook&version=1.0.6
For 4.8 Use Release x64 /!\
GlobalMouseHook
Author: FauZaPespi
Date: 13.11.2024
Tired of having to rehook for each project? Use this already pre-made hook to call events at the right time, everything is perfect, use us
Description
A .NET library designed to globally hook mouse events, providing real-time monitoring and simulation of mouse actions. This library enables developers to intercept, track, and simulate mouse clicks programmatically.
Features
Global Mouse Hooking:
- Tracks mouse button events globally across the system.
- Monitors cursor position during mouse events.
Mouse Button State Tracking:
- Detects and stores the state of the left and right mouse buttons (
IsKeepingLeftDown
,IsKeepingRightDown
).
- Detects and stores the state of the left and right mouse buttons (
Mouse Click Simulation:
- Simulate left and right mouse button presses and releases (
SendLeftDown
,SendLeftUp
,SendRightDown
,SendRightUp
).
- Simulate left and right mouse button presses and releases (
Customizable Event Handling:
- Raises a
GlobalMouseClick
event when a mouse button is pressed or released, with details of the button and cursor position.
- Raises a
Getting Started
Prerequisites
- .NET Framework or .NET Core compatible runtime.
- Administrative privileges to hook global system events.
Installation
Clone or download the repository and include the GlobalMouseHook
class in your project.
Usage
1. Set Up Global Mouse Hook
Instantiate the GlobalMouseHook
class to start monitoring mouse events globally.
var mouseHook = new GlobalMouseHook();
mouseHook.GlobalMouseClick += (button, position) =>
{
Console.WriteLine($"Button: {button}, Position: {position}");
};
2. Check Mouse Button States
Use these methods to check the current state of the mouse buttons:
bool isLeftButtonPressed = mouseHook.IsLeftDown();
bool isRightButtonPressed = mouseHook.IsRightDown();
bool isLeftHeld = mouseHook.IsKeepingLeftDown();
bool isRightHeld = mouseHook.IsKeepingRightDown();
3. Simulate Mouse Actions
Simulate mouse clicks programmatically:
mouseHook.SendLeftDown();
mouseHook.SendLeftUp();
mouseHook.SendRightDown();
mouseHook.SendRightUp();
4. Clean Up Resources
Unhook the mouse hook when it is no longer needed:
mouseHook.Unhook();
Functionality
Functionality | Description |
---|---|
SetHook() |
Sets up a global mouse hook using SetWindowsHookEx . |
Unhook() |
Releases the global mouse hook using UnhookWindowsHookEx . |
HookCallback() |
Processes mouse events and raises the GlobalMouseClick event. |
GlobalMouseClick (event) |
Raised when a mouse button is pressed or released, providing button name and cursor position. |
IsLeftDown() |
Checks if the left mouse button is currently pressed. |
IsRightDown() |
Checks if the right mouse button is currently pressed. |
IsKeepingLeftDown() |
Checks if the left mouse button is being held down. |
IsKeepingRightDown() |
Checks if the right mouse button is being held down. |
SendLeftDown() |
Simulates a left mouse button press. |
SendLeftUp() |
Simulates a left mouse button release. |
SendRightDown() |
Simulates a right mouse button press. |
SendRightUp() |
Simulates a right mouse button release. |
License
This project is licensed under the MIT License. See the LICENSE
file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.6 | 143 | 11/15/2024 |
Changing some package stuff but not the class content you know ?