Code Monkey home page Code Monkey logo

simplified-jna's Introduction

About

Simplified JNA is a library that allows for the quick creation of mouse and keyboard hooks in a multithreaded environment. Additionally it provides easy to use methods for sending inputs to window, mouse, and keyboard objects.

Usage

You can import this with maven via JitPack:

Add the repo to your pom:

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

And add the dependency:

	<dependency>
	    <groupId>com.github.Col-E</groupId>
	    <artifactId>Simplified-JNA</artifactId>
	    <version>1.0</version>
	</dependency>

Examples

In these samples, returing false allows the event to be parsed by the system. Chaning the return value to true will cancel the event.

Keyboard Hook

KeyEventReceiver keyHook = new KeyEventReceiver() {
    @Override
    public boolean onKeyUpdate(SystemState sysState, PressState pressState, int time, int vkCode) {
        System.out.println("Is pressed:" + (pressState == PressState.DOWN));
        System.out.println("Alt down:" + (sysState == SystemState.SYSTEM));
        System.out.println("Timestamp:" + time);
        System.out.println("KeyCode:" + vkCode);
        return false;
    }
};
KeyHook.hook(keyHook);

Mouse Hook

MouseEventReceiver mer = new MouseEventReceiver() {
    @Override
    public boolean  boolean onMousePress(MouseButtonType type, HWND hwnd, POINT info) {
        boolean isLeft = type == MouseButtonType.LEFT_DOWN;
        if (isLeft) {
            System.out.println("Left mouse button has been pressed!")
        }
        return false;
    }
    @Override public boolean onMouseRelease(MouseButtonType type, HWND hwnd, POINT info) { return false; }
    @Override public boolean onMouseScroll(boolean down, HWND hwnd, POINT info) { return false;  }
    @Override public boolean boolean onMouseMove(HWND hwnd, POINT info) { return false; }
};
MouseHook.hook(mer);

simplified-jna's People

Contributors

col-e avatar

Watchers

James Cloos 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.