如何使用Robot类在Java中发送CTRL

如何使用Robot类在Java中发送CTRL

本文介绍了如何使用Robot类在Java中发送CTRL + Z keyEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Java Robot class to send keyevents. I tried robot.keyPress() function. But I could not figure out how to send + 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).

这篇关于如何使用Robot类在Java中发送CTRL + Z keyEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:28