Use Robot to send combo key event : Robot « Development Class « Java

Use Robot to send combo key event


import java.lang.reflect.*;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class RobotUtilities {

    public static void sendKeysCombo(String keys[]) {
        try {

            Robot robot = new Robot();

            Class<?> cl = KeyEvent.class;

            int [] intKeys = new int [keys.length];

            for (int i = 0; i < keys.length; i++) {
                Field field = cl.getDeclaredField(keys[i]);
                intKeys[i] = field.getInt(field);

            for (int i = keys.length - 1; i >= 0; i--)
        catch (Throwable e) {

    // main for testing purposes
    public static void main(String args[]) {
        String [] keys = {
                "VK_CONTROL", "VK_SHIFT", "VK_F11"



Related examples in the same category

1.Moving the Cursor on the Screen
2.Simulate a key press
3.Simulate a mouse click
4.Create mouse event using Robot class
5.Capture a screenshot
6.Get the colour of a screen pixel
7.Capturing a Screen Shot
8.Capturing Screen in an image using Robot class
9.Create key press event using Robot class?
10.Use Robot to do mouse press
11.Using Robot to capture a screen shapshot