我正在使用Java Robot类发送键事件。我尝试了robot.keyPress()函数。但是我不知道如何发送CTRL + z keyEvent。

最佳答案

robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_Z)
// CTRL+Z is now pressed (receiving application should see a "key down" event.)
robot.keyRelease(KeyEvent.VK_Z)
robot.keyRelease(KeyEvent.VK_CONTROL)
// CTRL+Z is now released (receiving application should now see a "key up" event - as well as a "key pressed" event).

关于java - 如何使用Robot类在Java中发送CTRL + Z keyEvent,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9047710/

10-13 05:07