Java Robot KeyPress KeyRelease Not Working Mac

285 Views Asked by At

Everytime I execute a simplistic algorithim (where my IDE detects no errors), I keep getting the following error in my console:

java[4301:301618] pid(4301)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

This is quite confusing as I'm just using a for loop with what seems to be correct syntax with the Java Robot library on a Mac.

        Robot bot = new Robot();
        for(int i = 0; i < 20; i++) 
    {
        bot.keyPress(KeyEvent.VK_A);
        bot.keyRelease(KeyEvent.VK_A);
        Thread.sleep(500);
        System.out.println(i);
    }

What could be possibly wrong? Thanks!

0

There are 0 best solutions below