sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #11174
Re: [Question #126159]: How do I effect a left arrow key press with the type command?
Question #126159 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/126159
Lance Jensen posted a new comment:
The java class you are looking for is java.awt.Robot. Once you have
made a robot object you can do key presses and mouse moves/clicks.
Sulkui is great for some things but eventually I broke down and wrote
custom code most of my automation. One thing to watch out for is system
lag. Silkui is fairly resistant to system lag as the image recognition
functions as an interrupt handler with timeout. Hope this helps.
As for how to do a copy and paste with the Robot class:
// Get robot class
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
myRobot = new Robot(gs[0]);
// do copy opperation
myRobot.delay(50);
myRobot.keyPress(KeyEvent.VK_CONTROL);
type("c"); // type methods are below
myRobot.delay(50);
myRobot.keyRelease(KeyEvent.VK_CONTROL);
// do paste opperation
myRobot.delay(50);
myRobot.keyPress(KeyEvent.VK_CONTROL);
type("c"); // type methods are below
myRobot.delay(50);
myRobot.keyRelease(KeyEvent.VK_CONTROL);
private void type(String Text) {
char[] chars = Text.toCharArray();
int code;
for (int i = 0; i < chars.length; i++) {
// Parse the first character
typeKeyCode(chars[i]);
}
}
private void typeKeyCode(int c) {
myRobot.keyPress(c);
myRobot.delay(50);
myRobot.keyRelease(c);
}
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.