Git Product home page Git Product logo

globalmousekeyhook's Introduction

Build Status

Mouse and Keyboard Hooking Library in c#

What it does?

This library allows you to tap keyboard and mouse, to detect and record their activity even when an application is inactive and runs in background.

How?

This library attaches to windows global hooks, tracks keyboard and mouse clicks and movement and raises common .NET events with KeyEventArgs and MouseEventArgs, so you can easily retrieve any information you need:

  • Mouse coordinates
  • Mouse buttons clicked
  • Mouse wheel scrolls
  • Key presses and releases
  • Special key states

Additionally, there are MouseEventExtArgs and KeyEventExtArgs which provide further options:

  • Input suppression
  • Timestamp
  • IsMouseDown/Up
  • IsKeyDown/Up.
  • Background

History

Year URL
2000 - 2008 http://www.codeproject.com/KB/cs/globalhook.aspx
2008 - 2015 https://globalmousekeyhook.codeplex.com/
2015 - now https://github.com/gmamaladze/globalmousekeyhook

Installation

NuGet comming soon

Usage

private MouseHookListener m_mouseListener;

public void Activate()
{
    // Note: for an application hook, use the AppHooker class instead
    m_mouseListener = new MouseHookListener(new GlobalHooker());

    // The listener is not enabled by default
    m_mouseListener.Enabled = true;

    // Set the event handler
    // recommended to use the Extended handlers, which allow
    // input suppression among other additional information
    m_mouseListener.MouseDownExt += MouseListener_MouseDownExt;
}

public void Deactivate()
{
    m_mouseListener.Dispose();
}

private void MouseListener_MouseDownExt(object sender, MouseEventExtArgs e)
{
    // log the mouse click
    Console.WriteLine(
        string.Format(
            "MouseDown: \t{0}; \t System Timestamp: \t{1}",
            e.Button,
            e.Timestamp));

    // uncommenting the following line will suppress the middle mouse button click
    // if (e.Buttons == MouseButtons.Middle) { e.Handled = true; }
}

globalmousekeyhook's People

Contributors

gmamaladze avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.