emiln / cljck

An OS-agnostic Clojure library for automating keyboard and mouse actions.
GNU General Public License v3.0
5 stars 0 forks source link

Global keybinding to stop processing events #9

Closed emiln closed 9 years ago

emiln commented 9 years ago

It's almost impossible to stop the robot if you've set up a lot of movement and clicking. It would be great to have a global keybinding that would immediately stop event processing.

emiln commented 9 years ago

Perhaps jnativehook might do the trick.

Jnativehook definitely works. Just run boot -d com.1stleg/jnativehook:2.0.2 repl and execute the following code:

(ns cljck.test
  (:import [org.jnativehook GlobalScreen]
           [org.jnativehook.keyboard NativeKeyListener]))

(GlobalScreen/registerNativeHook)

(GlobalScreen/addNativeKeyListener
 (proxy [NativeKeyListener] []
   (nativeKeyPressed [e] (println "Pressed" (.getKeyCode e)))
   (nativeKeyReleased [e] (println "Released" (.getKeyCode e)))
   (nativeKeyTyped [e] (println "Typed" (.getKeyCode e)))))