Java Code Examples for org.jnativehook.NativeHookException#printStackTrace()

The following examples show how to use org.jnativehook.NativeHookException#printStackTrace() . 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: Keylogger.java    From SpyGen with Apache License 2.0 5 votes vote down vote up
public static void startKeylogger() {
    try {
        GlobalScreen.registerNativeHook();
    } catch(NativeHookException nhe) {
        nhe.printStackTrace();
    }
    GlobalScreen.getInstance().addNativeKeyListener(keyboard = new NativeKeyboard());
}
 
Example 2
Source File: KeyShortcutsPanel.java    From nanoleaf-desktop with MIT License 5 votes vote down vote up
private void startKeyListener()
{
	try
	{
		shortcutListener = new GlobalShortcutListener(shortcuts, devices);
		GlobalScreen.registerNativeHook();
		GlobalScreen.addNativeKeyListener(shortcutListener);
		Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
		logger.setLevel(Level.OFF);
	}
	catch (NativeHookException nhe)
	{
		nhe.printStackTrace();
		if (nhe.getMessage().equals("Failed to enable access for assistive devices.") &&
				System.getProperty("os.name").toLowerCase().contains("mac"))
		{
			new TextDialog(KeyShortcutsPanel.this.getFocusCycleRootAncestor(),
					"Please enable accessibility control to use the shortcuts feature.")
					.setVisible(true);
		}
	}
	catch (UnsatisfiedLinkError ule)
	{
		ule.printStackTrace();
		new TextDialog(KeyShortcutsPanel.this.getFocusCycleRootAncestor(),
				"Failed to setup shortcuts. Your platform may not be supported.")
				.setVisible(true);
	}
}
 
Example 3
Source File: HotKeysInterceptor.java    From MercuryTrade with MIT License 5 votes vote down vote up
public HotKeysInterceptor() {
    Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
    logger.setLevel(Level.OFF);

    logger.setUseParentHandlers(false);
    try {
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException e) {
        e.printStackTrace();
    }

    GlobalScreen.addNativeKeyListener(new MercuryNativeKeyListener());
    GlobalScreen.addNativeMouseListener(new MercuryNativeMouseListener());
}
 
Example 4
Source File: HotKeysInterceptor.java    From MercuryTrade with MIT License 5 votes vote down vote up
public static void main(String[] args) {
//        new HotKeysInterceptor();
        Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
        logger.setLevel(Level.OFF);

        logger.setUseParentHandlers(false);
        try {
            GlobalScreen.registerNativeHook();
        } catch (NativeHookException e) {
            e.printStackTrace();
        }
        GlobalScreen.addNativeMouseListener(new MercuryNativeMouseListener());
    }