<legend id='gVg0R'><style id='gVg0R'><dir id='gVg0R'><q id='gVg0R'></q></dir></style></legend>
<tfoot id='gVg0R'></tfoot>
    <bdo id='gVg0R'></bdo><ul id='gVg0R'></ul>
  • <small id='gVg0R'></small><noframes id='gVg0R'>

  • <i id='gVg0R'><tr id='gVg0R'><dt id='gVg0R'><q id='gVg0R'><span id='gVg0R'><b id='gVg0R'><form id='gVg0R'><ins id='gVg0R'></ins><ul id='gVg0R'></ul><sub id='gVg0R'></sub></form><legend id='gVg0R'></legend><bdo id='gVg0R'><pre id='gVg0R'><center id='gVg0R'></center></pre></bdo></b><th id='gVg0R'></th></span></q></dt></tr></i><div id='gVg0R'><tfoot id='gVg0R'></tfoot><dl id='gVg0R'><fieldset id='gVg0R'></fieldset></dl></div>

      1. 如何以编程方式生成按键事件?

        时间:2023-09-27
      2. <i id='qPCnB'><tr id='qPCnB'><dt id='qPCnB'><q id='qPCnB'><span id='qPCnB'><b id='qPCnB'><form id='qPCnB'><ins id='qPCnB'></ins><ul id='qPCnB'></ul><sub id='qPCnB'></sub></form><legend id='qPCnB'></legend><bdo id='qPCnB'><pre id='qPCnB'><center id='qPCnB'></center></pre></bdo></b><th id='qPCnB'></th></span></q></dt></tr></i><div id='qPCnB'><tfoot id='qPCnB'></tfoot><dl id='qPCnB'><fieldset id='qPCnB'></fieldset></dl></div>
          <tbody id='qPCnB'></tbody>
        <legend id='qPCnB'><style id='qPCnB'><dir id='qPCnB'><q id='qPCnB'></q></dir></style></legend>
        • <small id='qPCnB'></small><noframes id='qPCnB'>

          <tfoot id='qPCnB'></tfoot>

            <bdo id='qPCnB'></bdo><ul id='qPCnB'></ul>

                  本文介绍了如何以编程方式生成按键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  java 程序应该做的是它应该在某些情况下触发键盘按下,而无需人按下键盘键.因此,任何在 windows 中运行且需要键盘输入的程序都可以在没有人实际按下键盘的情况下获得输入.

                  What the java program should do is it should trigger keyboard press on some condition without a person pressing a keyboard key. So any program running in windows and in focus which requires keyboard input will get the input without a person actually pressing the keyboard.

                  我在这里找到了这些相关问题:问题1,问题2

                  I found these related questions here : question 1, question 2

                  我想知道在 Java 中是否有任何方法可以做到这一点.

                  I was wondering if there is any method to do this in Java.

                  推荐答案

                  使用 机器人 类.

                  代码片段:

                  import java.awt.Robot;
                  import java.awt.KeyEvent;
                  
                  Robot r = new Robot();
                  int keyCode = KeyEvent.VK_A; // the A key
                  r.keyPress(keyCode);
                  // later...
                  r.keyRelease(keyCode);
                  

                  但是,如果您尝试在计算机上自动执行一项任务,我建议您使用 AutoHotKey.它致力于自动化常见任务,因此使用它而不是 Java 会更容易.

                  However, if you are trying to automate a task on your computer, I would recommend AutoHotKey. It's dedicated to automating common tasks, so it would be easier to use it instead of Java.

                  这篇关于如何以编程方式生成按键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java 系统范围的键盘快捷键 下一篇:在 Java 中检测和操作键盘方向键

                  相关文章

                  最新文章

                  <tfoot id='hG9KK'></tfoot>
                  • <bdo id='hG9KK'></bdo><ul id='hG9KK'></ul>
                      <legend id='hG9KK'><style id='hG9KK'><dir id='hG9KK'><q id='hG9KK'></q></dir></style></legend>

                      <small id='hG9KK'></small><noframes id='hG9KK'>

                    1. <i id='hG9KK'><tr id='hG9KK'><dt id='hG9KK'><q id='hG9KK'><span id='hG9KK'><b id='hG9KK'><form id='hG9KK'><ins id='hG9KK'></ins><ul id='hG9KK'></ul><sub id='hG9KK'></sub></form><legend id='hG9KK'></legend><bdo id='hG9KK'><pre id='hG9KK'><center id='hG9KK'></center></pre></bdo></b><th id='hG9KK'></th></span></q></dt></tr></i><div id='hG9KK'><tfoot id='hG9KK'></tfoot><dl id='hG9KK'><fieldset id='hG9KK'></fieldset></dl></div>