gpt4 book ai didi

java - 自动打字机错误

转载 作者:行者123 更新时间:2023-12-01 13:41:18 25 4
gpt4 key购买 nike

我正在制作 Java 程序,为您输入预定义的消息。我不断收到 getRuntimeexec 的错误消息。我尝试用谷歌搜索但一无所获。我尝试更改项目中的设置并添加“抛出”,但似乎没有任何效果。我对 java 很陌生,所以请多多关照。

这是我当前的代码:

import java.awt.Robot;
import java.awt.event.KeyEvent;

public class main {

Runtime getRuntime() exec("notepad.exe");

Thread.sleep(2000);
Robot r=new Robot();
r.keyPress(KeyEvent.VK_T);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_H);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_I);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_S);
Thread.sleep(750);
r.keyPress(KeyEvent.VK_SPACE);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_I);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_S);
Thread.sleep(750);
r.keyPress(KeyEvent.VK_SPACE);
Thread.sleep(650);
r.keyPress(KeyEvent.VK_F);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_U);
Thread.sleep(500);
r.keyPress(KeyEvent.VK_N);
}}

最佳答案

尝试 Runtime.getRuntime().exec("notepad.exe");

关于java - 自动打字机错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20750415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com