Estou tentando desenvolver uma espécie de script p uso pessoal, através do JAVA.
Logo percebi q vou ter q utilizar o Runtime.getRuntime().exec() p realizar a tarefa q preciso, e então comecei a tentar utilizá-lo p testes. Logo no primeiro teste, funcionou. O modelo era:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
public class RobotTest {
public static void main(String[] args) throws IOException {
try {
Robot robot = new Robot();
Runtime.getRuntime().exec("C:\Windows\\notepad.exe");
robot.delay(5000);
robot.keyPress(KeyEvent.VK_O);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_M);
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_N);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_O);
} catch (AWTException e) {
e.printStackTrace();
}
}
}
Porém, quando tento realizar o mesmo processo, só que alterando o path do notepad p o meu desktop, o notepad n é executado. Mesmo quando jogo uma cópia do notepad.exe p desktop.
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
public class RobotTest {
public static void main(String[] args) throws IOException {
try {
Robot robot = new Robot();
Runtime.getRuntime().exec("C:\\Users\\WolfgänG\\Desktop\\notepad.exe");
robot.delay(5000);
robot.keyPress(KeyEvent.VK_O);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_M);
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_N);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_O);
} catch (AWTException e) {
e.printStackTrace();
}
}
}