机器人课粘贴到腻子终端

时间:2018-07-06 13:18:11

标签: java ssh putty awtrobot

我正在尝试通过使用implementation 'com.akexorcist:googledirectionlibrary:1.1.1' 类使用Java程序将字符串粘贴到putty命令提示符。

要粘贴,我必须按 GoogleDirection.withServerKey(serverKey) .from(startlatlng) .and(wayLatLng) .to(destlatlng) .transportMode(TransportMode.DRIVING) .execute(this); + Robot键。我想要做的是将字符串“ HelloWorld”粘贴到腻子命令提示符下。以下是我的代码。

shift

此代码按insert按钮,但不按package Auto; //Related imports public class Main { public static void main(String[] args) throws InterruptedException, AWTException { Runtime r = Runtime.getRuntime(); Process p; String username = "ABC"; String password = "DEF"; String serverString = "100.0.0.0"; String s = "C:\\Users\\ib\\Desktop\\Putty\\putty.exe -ssh -l " + username + " -pw " + password + " " + serverString + ""; try { p = r.exec(s); Thread.sleep(3000); } catch (Exception e) { System.out.println(e); e.printStackTrace(); } String text = "HelloWorld"; StringSelection stringSelection = new StringSelection(text); Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection,stringSelection); Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_SHIFT); Thread.sleep(150); robot.keyPress(KeyEvent.VK_INSERT); } } 按钮。有人可以指出我在这里做错了吗?

谢谢。

0 个答案:

没有答案