How to send CTRL+Z keyEvent in java using Robot class

前端 未结 1 1270
小鲜肉
小鲜肉 2020-12-19 03:48

I am using Java Robot class to send keyevents. I tried robot.keyPress() function. But I could not figure out how to send CTRL+z keyEvent.<

相关标签:
1条回答
  • 2020-12-19 04:01
    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).
    
    0 讨论(0)
提交回复
热议问题