3

After macOS was upgraded to Mojave, java application that is using Java Robot and works absolutely fine under High Sierra, stars to work incorrectly. Symptoms are:

  • robot.keyPress(VK_N); causes the about 7 the same errors and did not type anything.

    2019-02-03 19:27:52.324 java[928:31672] pid(928)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is is NOT allowed. Please call TIS/TSM in main thread!!!

  • robot.mouseMove works fine if I run it via Java command line, and doesn't work if I run the same class in Eclipse.

    public static void main( String[] arg) throws AWTException, InterruptedException {
       Robot robot;
       robot = new Robot();
    
        robot.waitForIdle();
        robot.keyPress(VK_N);
        robot.keyRelease(VK_N);
    
        robot.waitForIdle();
        robot.mouseMove(100, 100);
        Thread.sleep(500);
        robot.mouseMove(10, 10);
    }    
    

According to the recommendation Robot.mouseMove does not work at all in Mac OS X I have added Java and Eclipse into Security & Privacy, click the Privacy tab toward the top, then choose Accessibility. It did not solve the problem. Moreover, I could not see any difference.

I went through this link https://eclecticlight.co/2018/09/17/managing-mojaves-privacy-protection-privacy-controls/ and ran "tccutil reset AppleEvents". But I did not get expected the dialog to add the pair of apps into Privacy=>Automation section of "System preferences"

my Java is 1.8.0_191, x86_64.

Any ideas how to get that code to work in Mac OS Mojave?

Best Regards,

1 Answers1

2

Not sure if you found the solution already. If not, follow the steps below,

  1. Settings -> Security & Privacy
  2. Scroll down to "Accessibility"
  3. Click the lock button at the bottom and unlock the security and privacy preferences
  4. Click on '+' icon and your program (Eclipse IDE in my case) and try running again

The IDE still shows "This is NOT allowed. Please call TIS/TSM in main thread!!!" but both Keyboard and Mouse events work. I checked your code as well.

Elango
  • 51
  • 3