Skip to content

macote/Winook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

127 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nuget

Winook is a Windows library that lets you install thread-level hooks inside processes. This library offers an alternative to solutions that use global hooks. With thread-level hooks, performance and management issues can be avoided.

Information

Winook uses host processes and DLL injection to set up hooks. Both 32-bit and 64-bit support host applications and DLLs are included.

Features

  • Works in .NET Framework and .NET Core applications
  • 32-bit and 64-bit dynamic support
  • Mouse and keyboard specific message handlers
    • Extensive keyboard modifiers support
  • Mouse message filtering at dll level
    • Ability to ignore mouse move messages to improve performance

Application

  • Game Helpers
    • Winook can be used in game helpers. In-game keyboard and mouse events can be tied to event handlers in your application. For example, Winook is used in Poe Lurker to provide additional trading functionality.
  • Application Inspection
    • Winook can be used as a telemetry inspection tool.
  • Other Uses
    • Please share how you use Winook!

Installation

NuGet

Install-Package Winook -Version 1.4.0

Usage

private async Task InstallHooksAsync()
{
    _process = Process.Start(@"c:\windows\system32\charmap.exe");
    //_process = Process.Start(@"c:\windows\syswow64\charmap.exe"); // works also with 32-bit
    await Task.Delay(1000);

    _mouseHook = new MouseHook(_process.Id);
    //_mouseHook = new MouseHook(_process.Id, MouseMessageTypes.IgnoreMove);
    _mouseHook.MessageReceived += MouseHook_MessageReceived;
    //_mouseHook.LeftButtonUp += MouseHook_LeftButtonUp;
    //_mouseHook.AddHandler(MouseMessageCode.NCLeftButtonUp, MouseHook_NCLButtonUp);
    await _mouseHook.InstallAsync();

    _keyboardHook = new KeyboardHook(_process.Id);
    _keyboardHook.MessageReceived += KeyboardHook_MessageReceived;
    //_keyboardHook.AddHandler(KeyCode.Y, Modifiers.ControlShift, KeyboardHook_ControlShiftY);
    await _keyboardHook.InstallAsync();
}

...

private void MouseHook_MessageReceived(object sender, MouseMessageEventArgs e)
{
    Debug.Write($"Code: {e.MessageCode}; X: {e.X}; Y: {e.Y}; Modifiers: {e.Modifiers:x}; ");
    Debug.WriteLine($"Delta: {e.Delta}; XButtons: {e.XButtons}; Sent: {e.SendTimestamp:O}");
}

private void KeyboardHook_MessageReceived(object sender, KeyboardMessageEventArgs e)
{
    Debug.Write($"Code: {e.KeyValue}; Modifiers: {e.Modifiers:x}; Flags: {e.Flags:x}; ");
    Debug.WriteLine($"Shift: {e.Shift}; Control: {e.Control}; Alt: {e.Alt}; Direction: {e.Direction}; Sent: {e.SendTimestamp:O}");
}

License

MIT

Acknowledgements

Thanks to C1rdec for the inspiration and motivation. I created this initially to help him with his project.

Sponsor this project

Packages

 
 
 

Contributors