Invoking menu actions using java.awt.Robot

I am trying to write a simple plugin that invokes different actions using shortcuts. But for some reason its not working even if I have an active editor.

For example here is a simple snippet that invokes COMMAND + A (select all text).:

ApplicationManager.getApplication().invokeLater(new Runnable() {
                        public void run() {
                            try {
                                Robot robot = new Robot();
                            } catch (AWTException e) {

However, even COMMAND + Q is not recognized. I started this route because it seems easier to invoke actions without having to construct them by hand but I am not getting anywhere. Any help/suggestions most welcome!


1 comment
Comment actions Permalink

It's better to work with action instances directly - you can get registered actions from ActionManager instance. If you need to work with shortcuts, check KeymapManager and Keymap classes, they provide mappings between action ids and keyboard/mouse shortcuts.


Please sign in to leave a comment.