← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #254203]: Hotkey Listener overrides hotkey use

 

Question #254203 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/254203

    Status: Answered => Solved

Max confirmed that the question is solved:
I ended up using java.awt.Robot, works as I'd like it to now. Thanks for
the answers though!

final HotkeyListener listener = new HotkeyListener() {
            @Override
            public void hotkeyPressed(HotkeyEvent hotkeyEvent) {
                try {
                    HotkeyManager.getInstance().removeHotkey(key, modifiers);
                    Robot robot = new Robot();
                    robot.keyPress(KeyEvent.CTRL_DOWN_MASK);
                    robot.delay(100);
                    robot.keyPress(KeyEvent.VK_C);
                    robot.delay(50);
                    robot.keyRelease(KeyEvent.VK_C);
                    robot.delay(100);
                    robot.keyRelease(KeyEvent.CTRL_DOWN_MASK);
                    robot.delay(1000);
                    copyListener.executeCopy();
                    HotkeyManager.getInstance().addHotkey(key, modifiers, this);
                } catch (AWTException e) {
                    e.printStackTrace();
                }
            }
        };

A bit tricky playing around with the delays, but it doesn't need to be
fast so it's fine

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.