在Windows PC上,如何使用Java';s机器人关闭屏幕键盘窗口?

在Windows PC上,如何使用Java';s机器人关闭屏幕键盘窗口?,java,windows,on-screen-keyboard,Java,Windows,On Screen Keyboard,我的Java应用程序需要打开屏幕上的键盘应用程序[osk.exe],然后使用Java Robot将鼠标移动到关闭按钮位置并按下鼠标关闭应用程序,但它不会关闭,但当我单击鼠标时,它确实关闭了应用程序,为什么?如何使用Java Robot关闭它 以下是我的示例代码: try { Runtime.getRuntime().exec("cmd.exe /c osk.exe"); Robot robot=new Robot(); robot.delay(100);

我的Java应用程序需要打开屏幕上的键盘应用程序[osk.exe],然后使用Java Robot将鼠标移动到关闭按钮位置并按下鼠标关闭应用程序,但它不会关闭,但当我单击鼠标时,它确实关闭了应用程序,为什么?如何使用Java Robot关闭它

以下是我的示例代码:

  try
  {
    Runtime.getRuntime().exec("cmd.exe /c osk.exe");
    Robot robot=new Robot();
    robot.delay(100);           // Delay to let the application load
    robot.mouseMove(1750,880);  // Move to On_Screen Keyboard's [ osk.exe ] upper right corner where the close button [ X ] is.
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
  }
  catch (Exception e) { e.printStackTrace(); }

不确定此处的
robot
标记是否合适。为什么要通过robot关闭osk?