Java Code Examples for org.jnativehook.GlobalScreen#unregisterNativeHook()
The following examples show how to use
org.jnativehook.GlobalScreen#unregisterNativeHook() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Recorder.java From SikuliX1 with MIT License | 6 votes |
private static void unregisterNativeHook() { try { /* * We unregister the native hook on Windows because it blocks some special keys * in AWT while registered (e.g. AltGr). * * We do not unregister on Linux because this terminates the whole JVM. * Interestingly, the special keys are not blocked on Linux at all. * * TODO: Has to be checked on Mac OS, but I guess that not unregistering is * the better option here. * * Re-registering doesn't hurt anyway, because JNativeHook checks the register * state before registering again. So unregister is only really needed on Windows. */ if (Settings.isWindows()) { GlobalScreen.unregisterNativeHook(); } } catch (NativeHookException e) { Debug.error("Error unregistering native hook: %s", e.getMessage()); } }
Example 2
Source File: PmTrans.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
private PmTrans(GlobalKeyListener gkl) { // Initialize the interface d = new Display(); shell = new Shell(d); menuManager = new MenuManager(shell, this); barManager = new BarManager(shell, this); // Global keys this.gKL = gkl; initState(); initGui(); startAutoSave(); shell.open(); while (!shell.isDisposed()) if (!d.readAndDispatch()) d.sleep(); if (player != null) { player.close(); player = null; } GlobalScreen.unregisterNativeHook(); saveState(); try { Config.getInstance().save(); } catch (IOException e) { // ignore } }
Example 3
Source File: GlobalKeyListener.java From foolqq with BSD 2-Clause "Simplified" License | 5 votes |
public void nativeKeyPressed(NativeKeyEvent e) { if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) { try { GlobalScreen.unregisterNativeHook(); System.exit(1); } catch (NativeHookException e1) { } } }
Example 4
Source File: MouseEventNotificator.java From DeskChan with GNU Lesser General Public License v3.0 | 5 votes |
/** * Call this static method when you don't need to listen to events anymore. * It unregisters native hook and stops catching mouse events at all. */ static void disableHooks() { try { GlobalScreen.unregisterNativeHook(); } catch (NativeHookException | UnsatisfiedLinkError e) { e.printStackTrace(); } }
Example 5
Source File: GlobalListenerHookController.java From Repeat with Apache License 2.0 | 5 votes |
public void cleanup() { if (GlobalListenerFactory.USE_JNATIVE_HOOK) { try { GlobalScreen.unregisterNativeHook(); } catch (NativeHookException e) { LOGGER.log(Level.WARNING, "Unable to unregister JNative Hook.", e); } } else { NativeHookInitializer.of().stop(); } }
Example 6
Source File: MainFm.java From tools-ocr with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void stop() throws Exception { GlobalScreen.unregisterNativeHook(); }