将KeyStrokes发送到后台的应用程序。爪哇

时间:2018-07-04 03:10:35

标签: java bots

我正在尝试将击键发送到程序,更具体地说是Java的RPG。我想反复按字母C约30秒,然后按左右键重复。到目前为止,这是我想出的:

package HealBot;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import javax.swing.*;


public class HealBot {

    public static void main(String[] args) throws AWTException,IOException{

        final Robot rob = new Robot();
        boolean on = true;
        while(on) {
            for(int i = 0; i<40; i++) {
                rob.keyPress(KeyEvent.VK_C);
                rob.delay(500);
            }

            rob.keyPress(KeyEvent.VK_LEFT);
            rob.delay(400);
            rob.keyPress(KeyEvent.VK_RIGHT);
            rob.delay(400);

        }
    }



}

0 个答案:

没有答案