Convert Figma logo to code with AI

oblitum logoInterception

The Interception API aims to build a portable programming interface that allows one to intercept and control a range of input devices.

1,475
287
1,475
55

Top Related Projects

AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.

Quick Overview

Interception is a low-level keyboard and mouse hooking library for Windows. It allows developers to intercept and manipulate input device events, providing a powerful tool for creating custom input handling solutions, macro systems, or advanced input processing applications.

Pros

  • Low-level access to keyboard and mouse events
  • Supports a wide range of input devices, including specialized gaming peripherals
  • Provides both C and C++ APIs for flexibility
  • Allows for creating complex input manipulation systems

Cons

  • Windows-only, limiting cross-platform compatibility
  • Requires administrative privileges to install and run, which may pose security concerns
  • Limited documentation and examples available
  • Potential for misuse in creating malicious software

Code Examples

  1. Intercepting keyboard events:
#include <iostream>
#include "interception.h"

int main()
{
    InterceptionContext context;
    InterceptionDevice device;
    InterceptionStroke stroke;

    context = interception_create_context();

    interception_set_filter(context, interception_is_keyboard, INTERCEPTION_FILTER_KEY_DOWN | INTERCEPTION_FILTER_KEY_UP);

    while (interception_receive(context, device = interception_wait(context), &stroke, 1) > 0)
    {
        if (interception_is_keyboard(device))
        {
            InterceptionKeyStroke &keystroke = *(InterceptionKeyStroke *) &stroke;
            std::cout << "Key event: " << keystroke.code << " " << (keystroke.state & INTERCEPTION_KEY_UP ? "up" : "down") << std::endl;
        }
    }

    interception_destroy_context(context);
    return 0;
}
  1. Intercepting mouse events:
#include <iostream>
#include "interception.h"

int main()
{
    InterceptionContext context;
    InterceptionDevice device;
    InterceptionStroke stroke;

    context = interception_create_context();

    interception_set_filter(context, interception_is_mouse, INTERCEPTION_FILTER_MOUSE_MOVE | INTERCEPTION_FILTER_MOUSE_BUTTON_DOWN | INTERCEPTION_FILTER_MOUSE_BUTTON_UP);

    while (interception_receive(context, device = interception_wait(context), &stroke, 1) > 0)
    {
        if (interception_is_mouse(device))
        {
            InterceptionMouseStroke &mousestroke = *(InterceptionMouseStroke *) &stroke;
            std::cout << "Mouse event: x=" << mousestroke.x << ", y=" << mousestroke.y << ", state=" << mousestroke.state << std::endl;
        }
    }

    interception_destroy_context(context);
    return 0;
}
  1. Sending a simulated key press:
#include "interception.h"

int main()
{
    InterceptionContext context;
    InterceptionDevice device;
    InterceptionKeyStroke keystroke;

    context = interception_create_context();

    device = interception_wait(context);
    
    keystroke.code = 0x1E; // 'A' key
    keystroke.state = INTERCEPTION_KEY_DOWN;
    interception_send(context, device, (InterceptionStroke *)&keystroke, 1);

    keystroke.state = INTERCEPTION_KEY_UP;
    interception_send(context, device, (InterceptionStroke *)&keystroke, 1);

    interception_destroy_context(context);
    return 0;
}

Getting Started

  1. Download and install the Interception driver from the project's GitHub repository.
  2. Include the Interception header files in your project.
  3. Link against the Interception library.
  4. Use the provided API functions to create a context, set filters, and handle input events.
  5. Compile and run your program with administrative privileges.

Note: Ensure you have the necessary development tools and Windows SDK installed for compiling C/C++ applications.

Competitor Comparisons

AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.

Pros of AutoHotkey

  • More user-friendly scripting language, easier for beginners
  • Extensive documentation and large community support
  • Built-in GUI creation capabilities

Cons of AutoHotkey

  • Limited to Windows operating system
  • Less precise for low-level input manipulation
  • Performance may be slower for complex operations

Code Comparison

AutoHotkey:

^!n::
Run Notepad
return

Interception:

#include <interception.h>

int main(void)
{
    InterceptionContext context;
    InterceptionDevice device;
    InterceptionStroke stroke;

    context = interception_create_context();
    interception_set_filter(context, interception_is_keyboard, INTERCEPTION_FILTER_KEY_DOWN | INTERCEPTION_FILTER_KEY_UP);

    while (interception_receive(context, device = interception_wait(context), &stroke, 1) > 0)
    {
        // Handle input here
    }

    interception_destroy_context(context);
    return 0;
}

The code comparison shows that AutoHotkey offers a more concise syntax for simple tasks, while Interception provides lower-level control but requires more complex setup and handling. AutoHotkey is better suited for quick scripting and automation, whereas Interception excels in scenarios requiring precise input manipulation and cross-platform compatibility.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Interception

Download the latest release

Building

Source code is built upon Windows Driver Kit Version 7.1.0.

Simple build scripts (buildit.cmd) are provided to build using specific build environments of the WDK, they require the environment variable %WDK% to be previously set to the WDK installation directory.

  • Tested from Windows XP to Windows 10.

Driver installation

Drivers can be installed through the command line installer, but driver installation requires execution inside a prompt with administrative rights.

Run install-interception without any arguments inside an console executed as administrator and it will give instructions for installation.

License

Interception is dual-licensed.

For non-commercial purposes it adopts LGPL for the library and its source code, with rights of distribution of the related binary assets (drivers and installers ) once communication with drivers happen solely by use of the library and its API.

For commercial purposes it adopts two other licenses which can be checked in the licenses directory:

  • Interception API License:
    It's similar to the non-commercial license, solely removing restrictions for commercial usage.
    It also includes an additional asset which is an installer library, so that driver installation can be embedded silently in your own installer.

  • Interception License:
    Provides access to all source code, including drivers and installers.

Please contact me at francisco@oblita.com for acquiring a commercial license.

Use cases

Interception has been used around the world in cases I couldn't imagine when I first created it:

  • Helping people with accessibility limitations, tailoring systems according to their limitations.
  • By companies in aviation training, to connect many devices at once and customizing each one.
  • By companies providing SCADA (supervisory control and data acquisition) solutions.
  • In game applications like BOTs and control customization.
  • To construct an emacs mode of the system.
  • To customize supermarket cashier's systems.
  • In doctoral thesis about typing pattern recognition for security applications.
  • Home theater automation.
  • ...

For fun:

lissajous rose butterfly

© 2008 Francisco Lopes