Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.imoz;
- import java.io.IOException;
- import org.jnativehook.GlobalScreen;
- import org.jnativehook.NativeHookException;
- import org.jnativehook.mouse.NativeMouseEvent;
- import org.jnativehook.mouse.NativeMouseInputListener;
- public class MouseHide implements NativeMouseInputListener {
- boolean hidden = false;
- public void nativeMouseClicked(NativeMouseEvent e) {
- if(e.getClickCount() == 2)
- {
- Process p;
- if(hidden)
- hidden = false;
- else
- hidden = true;
- try {
- p = Runtime.getRuntime().exec("defaults write com.apple.finder CreateDesktop -bool " + hidden);
- p.waitFor();
- p = Runtime.getRuntime().exec("killall Finder");
- p.waitFor();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- }
- public void nativeMousePressed(NativeMouseEvent e) {
- //System.out.println("Mosue Pressed: " + e.getButton());
- }
- public void nativeMouseReleased(NativeMouseEvent e) {
- //System.out.println("Mosue Released: " + e.getButton());
- }
- public void nativeMouseMoved(NativeMouseEvent e) {
- //System.out.println("Mosue Moved: " + e.getX() + ", " + e.getY());
- }
- public void nativeMouseDragged(NativeMouseEvent e) {
- //System.out.println("Mosue Dragged: " + e.getX() + ", " + e.getY());
- }
- public static void main(String[] args) {
- try {
- GlobalScreen.registerNativeHook();
- }
- catch (NativeHookException ex) {
- System.err.println("There was a problem registering the native hook.");
- System.err.println(ex.getMessage());
- System.exit(1);
- }
- //Construct the example object.
- MouseHide example = new MouseHide();
- //Add the appropriate listeners for the example object.
- GlobalScreen.getInstance().addNativeMouseListener(example);
- GlobalScreen.getInstance().addNativeMouseMotionListener(example);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment