# Simplified-JNA
**Repository Path**: alvin_swing/Simplified-JNA
## Basic Information
- **Project Name**: Simplified-JNA
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-10-12
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 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:
```
jitpack.io
https://jitpack.io
```
And add the dependency:
```
com.github.Col-E
Simplified-JNA
1.0
```
#### 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
```java
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
```java
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);
```