本文整理汇总了Java中org.jnativehook.GlobalScreen.addNativeKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalScreen.addNativeKeyListener方法的具体用法?Java GlobalScreen.addNativeKeyListener怎么用?Java GlobalScreen.addNativeKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnativehook.GlobalScreen
的用法示例。
在下文中一共展示了GlobalScreen.addNativeKeyListener方法的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...");
}
}
示例2: 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();
}
}
示例3: 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());
}
示例4: 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");
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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");
}
}
示例8: 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());
}
示例9: 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);
}
示例10: 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());
}
示例11: 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);
}
示例12: setupKeyHook
import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
/**
* sets up the keyhook.
*/
public static void setupKeyHook() {
// 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);
}
x = new KeyHook();
GlobalScreen.addNativeKeyListener(x);
}
示例13: BaseQQWindowContext
import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public BaseQQWindowContext(File point) throws AWTException, IOException, NativeHookException {
robot = new Robot();
pImage = ImageIO.read(point);
WindowHandleTask wintask = new WindowHandleTask(this, map, robot);
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(wintask, checkInterval, checkInterval,
TimeUnit.SECONDS);
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
logger.setUseParentHandlers(false);
GlobalScreen.registerNativeHook();
GlobalScreen.addNativeKeyListener(new GlobalKeyListener());
}
示例14: keyListenStart
import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
public void keyListenStart() throws NativeHookException {
GlobalScreen.addNativeKeyListener(spKeylistener);
GlobalScreen.registerNativeHook();
// Get the logger for "org.jnativehook" and set the level to warning.
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.WARNING);
// Don't forget to disable the parent handlers.
logger.setUseParentHandlers(false);
}
示例15: initVirtualizer
import org.jnativehook.GlobalScreen; //导入方法依赖的package包/类
private void initVirtualizer() {
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);
}
LogManager.getLogManager().reset();
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
GlobalScreen.addNativeKeyListener(this);
}