com.tulskiy.keymaster.common.HotKey Java Examples

The following examples show how to use com.tulskiy.keymaster.common.HotKey. 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: HotkeyController.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Override
public void onHotKey(HotKey hotKey) {
  if (isOldFashion()) {
    int nkey = oldFashionedKeys.get(key);
    int nmod = oldFashionedKeys.get(modifier);
    org.sikuli.basics.HotkeyEvent hotkeyEvent = new org.sikuli.basics.HotkeyEvent(nkey, nmod);
    ((HotkeyListener) callback).hotkeyPressed(hotkeyEvent);
  } else {
    ((HotkeyCallback) callback).hotkeyPressed(new HotkeyEvent(key, modifier));
  }
}
 
Example #2
Source File: WindowsProvider.java    From SikuliX1 with MIT License 5 votes vote down vote up
private void register(HotKey hotKey) {
    int id = idSeq++;
    int code = KeyMap.getCode(hotKey);
    if (RegisterHotKey(null, id, KeyMap.getModifiers(hotKey.keyStroke), code)) {
        //LOGGER.info("Registering hotkey: " + hotKey);
        hotKeys.put(id, hotKey);
    } else {
        //LOGGER.warn("Could not register hotkey: " + hotKey);
    }
}
 
Example #3
Source File: GlobalHotkey.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init() {
    provider.register(KeyStroke.getKeyStroke(GLOBAL_HOTKEY), new HotKeyListener() {
        public void onHotKey(HotKey hotKey) {
            if (!ui.isWindowMinimized() && ui.isWindowFocused()) {
                Platform.runLater(() -> ui.minimizeWindow());
                ui.getBrowserComponent().minimizeWindow();
            } else {
                Platform.runLater(() -> ui.setDefaultWidth());
                ui.getBrowserComponent().focus(ui.getMainWindowHandle());
            }
        }
    });
}
 
Example #4
Source File: WindowsProvider.java    From SikuliX1 with MIT License 4 votes vote down vote up
public void register(KeyStroke keyCode, HotKeyListener listener) {
    synchronized (lock) {
        registerQueue.add(new HotKey(keyCode, listener));
    }
}
 
Example #5
Source File: WindowsProvider.java    From SikuliX1 with MIT License 4 votes vote down vote up
public void register(MediaKey mediaKey, HotKeyListener listener) {
    synchronized (lock) {
        registerQueue.add(new HotKey(mediaKey, listener));
    }
}
 
Example #6
Source File: ScreenStudio.java    From screenstudio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates new form MainVersion3
 */
public ScreenStudio() {
    initComponents();

    this.setIconImage(new ImageIcon(ScreenStudio.class.getResource("/screenstudio/gui/images/icon.png")).getImage());
    initControls();
    updateColumnsLayout();
    mLayoutPreview = new SourceLayoutPreview(tableSources, mSources);
    mLayoutPreview.setOutputWidth((Integer) spinWidth.getValue());
    mLayoutPreview.setOutputHeight((Integer) spinHeight.getValue());
    panPreviewLayout.add(mLayoutPreview, BorderLayout.CENTER);
    this.setTitle("ScreenStudio " + screenstudio.Version.MAIN);
    //this.setSize(700, 500);
    this.pack();
    ToolTipManager.sharedInstance().setDismissDelay(8000);
    ToolTipManager.sharedInstance().setInitialDelay(2000);
    new Thread(() -> {
        if (Version.hasNewVersion()) {
            lblMessages.setText(LANGUAGES.getString("MSG_NEW_VERSION_AVAILABLE"));
        }
        String text = "";
        for (String msg : SystemCheck.getSystemCheck(false)) {
            text = text + msg + "\n ";
        }
        if (text.length() > 0) {
            lblMessages.setText(text);
            lblMessages.setForeground(Color.red);
            lblMessages.setToolTipText("<HTML><BODY>" + text.replaceAll("\n", "<BR>") + "</BODY></HTML>");
        }
    }).start();
    mShortcuts = Provider.getCurrentProvider(false);
    mShortcuts.register(KeyStroke.getKeyStroke("control shift R"), new HotKeyListener() {
        @Override
        public void onHotKey(HotKey hotkey) {
            System.out.println("Hotkey: " + hotkey.toString());
            switch (hotkey.keyStroke.getKeyCode()) {
                case KeyEvent.VK_R:
                    mnuCapture.doClick();
                    break;
            }
        }
    });
    mRemote = new HTTPServer(null, null, mnuCapture);
    new Thread(mRemote).start();
    try {
        lblRemoteMessage.setText(LANGUAGES.getString("REMOTE_ACCESS") + ": http://" + Inet4Address.getLocalHost().getHostName() + ".local:" + mRemote.getPort());
    } catch (UnknownHostException ex) {
        Logger.getLogger(ScreenStudio.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #7
Source File: HotkeyManager.java    From SikuliNG with MIT License 4 votes vote down vote up
@Override
public void onHotKey(HotKey hotKey) {
  callback.hotkeyPressed(new HotkeyEvent(key, modifier));
}