java.awt.Robot.delay()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中java.awt.Robot.delay方法的一些代码示例,展示了Robot.delay的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Robot.delay方法的具体详情如下:
包路径:java.awt.Robot
类名称:Robot
方法名:delay

Robot.delay介绍

暂无

代码示例

代码示例来源:origin: RaiMan/SikuliX2

public void pause(int ms) {
 if (ms < 0) {
  return;
 }
 while (ms > MAX_DELAY) {
  super.delay(MAX_DELAY);
  ms -= MAX_DELAY;
 }
 super.delay(ms);
}
//</editor-fold>

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import java.util.*;
public class Hal{

  public static void main(String[] args) throws Exception{
    Robot hal = new Robot();
    Random random = new Random();
    while(true){
      hal.delay(1000 * 60);
      int x = random.nextInt() % 640;
      int y = random.nextInt() % 480;
      hal.mouseMove(x,y);
    }
  }
}

代码示例来源:origin: stackoverflow.com

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

public class Notepad {

  static int keyInput[] = { KeyEvent.VK_J, KeyEvent.VK_A, KeyEvent.VK_V,
      KeyEvent.VK_A, KeyEvent.VK_SPACE };

  public static void main(String[] args) throws Exception {

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

    Robot robot = new Robot();
    for (int i = 0; i < keyInput.length; i++) {
      robot.keyPress(keyInput[i]);
      robot.delay(100);
    }
  }
}

代码示例来源:origin: RaiMan/SikuliX2

public void focusBelow() {
 if (SX.isMac()) {
  // TODO: replace this hack with a more robust method
  // Mac's hack to bring focus to the window directly underneath
  // this hack works on the assumption that the caller has
  // the input focus but no interaction area at the current
  // mouse cursor position
  // This hack does not work well with applications that
  // can receive mouse clicks without having the input focus
  // (e.g., finder, system preferences)
  //         robot.mousePress(InputEvent.BUTTON1_MASK);
  //         robot.mouseRelease(InputEvent.BUTTON1_MASK);
  // Another temporary hack to switch to the previous window on Mac
  robot.keyPress(KeyEvent.VK_META);
  robot.keyPress(KeyEvent.VK_TAB);
  robot.keyRelease(KeyEvent.VK_META);
  robot.keyRelease(KeyEvent.VK_TAB);
  // wait a little bit for the switch to complete
  robot.delay(1000);
 }
}

代码示例来源:origin: com.sikulix/sikulixapi

@Override
public void delay(int ms) {
 if (ms < 0) {
  return;
 }
 while (ms > MAX_DELAY) {
  super.delay(MAX_DELAY);
  ms -= MAX_DELAY;
 }
 super.delay(ms);
}

代码示例来源:origin: us.ihmc/ihmc-java-toolkit

@Override
public void playback(java.awt.Robot awtRobot, double playbackSpeed)
{
 awtRobot.delay((int) (delayInSeconds / playbackSpeed * 1000));
}

代码示例来源:origin: net.officefloor.tool/officetool_demo

/**
 * Delays for the press/release.
 */
private void delayForPressRelease() {
  if (this.isRequirePressReleaseDelay) {
    this.robot.delay(MIN_PRESS_RELEASE_DELAY);
  }
}

代码示例来源:origin: org.sikuli/sikuli-api

public void delay(int ms){
  if(ms<0)
    ms = 0;
  while(ms>MAX_DELAY){
    super.delay(MAX_DELAY);
    ms -= MAX_DELAY;
  }
  super.delay(ms);
}

代码示例来源:origin: com.infotel.seleniumRobot/grid-extensions

public void typeKeys(final String text) {
  if (text != null) {
    for (int i = 0; i < text.length(); i++) {
      typeKey(text.charAt(i));
      robot.delay(50);
    }
  }
}

代码示例来源:origin: stackoverflow.com

Robot r = new Robot();
doLeftMouseClick(r, 272, 241);
r.delay(1000);
doLeftMouseClick(r, 272, 241);
r.keyPress(KeyEvent.SHIFT_MASK);

代码示例来源:origin: stackoverflow.com

Robot robot = new Robot();

if(interacting)
{
  robot.keyPress(VK_A);
  robot.delay(20); //to simulate the normal keyboard rate
  robot.keyRelease(VK_A);
  robot.delay(20); //to simulate the normal keyboard rate
}

代码示例来源:origin: stackoverflow.com

Robot divideWindow = new Robot();
divideWindow.keyPress(KeyEvent.VK_WINDOWS);
divideWindow.delay(100);
divideWindow.keyPress(KeyEvent.VK_LEFT);
divideWindow.delay(100);
divideWindow.keyRelease(KeyEvent.VK_LEFT);
divideWindow.delay(100);
divideWindow.keyRelease(KeyEvent.VK_WINDOWS);

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws IOException, AWTException
{       
  // Move it to here:
  Key keyObject = new Key();

  JFrame.addKeyListener(keyObject);
  final Robot robot = new Robot();
  robot.delay(2000);

  while(keyObject.spacebarPressed())
  {
....

代码示例来源:origin: stackoverflow.com

// Start Robot in a new thread.
new Thread(new Runnable() {
  @Override
  public void run() {
    Robot robot = new Robot();
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_ESCAPE);
  }
}).start();

// Launch JFileChooser.
jFileChooser.getSelectedFile();

代码示例来源:origin: stackoverflow.com

public class MoveMouse {

  Robot ro;

  public MoveMouse(int x, int y) throws AWTException{
    ro = new Robot();
    ro.mouseMove(x, y);
    ro.delay(1000); // 1 second delay
  }
}

代码示例来源:origin: stackoverflow.com

try {
  Robot robot = new Robot();
  robot.keyPress(KeyEvent.VK_ENTER);
  robot.keyRelease(KeyEvent.VK_ENTER);
  robot.delay(200);
}

代码示例来源:origin: org.xworker/xworker_core

public static void delay(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext);
  int ms = self.getInt("ms");
  robot.delay(ms);
}

代码示例来源:origin: stackoverflow.com

Robot robot = new Robot();
robot.delay(1000);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.delay(1000);

代码示例来源:origin: stackoverflow.com

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

Robot r = new Robot();
r.setAutoDelay(100);
r.delay(500);
r.keyPress(KeyEvent.VK_H);
r.keyPress(KeyEvent.VK_E);
r.keyPress(KeyEvent.VK_L);
r.keyPress(KeyEvent.VK_L);
r.keyPress(KeyEvent.VK_O);

代码示例来源:origin: stackoverflow.com

Robot r = new Robot();
r.keyPress(KeyEvent.VK_ALT);
r.keyPress(KeyEvent.VK_TAB);
r.delay(10); //set the delay
r.keyRelease(KeyEvent.VK_ALT);
r.keyRelease(KeyEvent.VK_TAB);

相关文章