Ejemplo n.º 1
0
    public void run() {
      try {
        if (myPreviousThread != null) myPreviousThread.join();
        Thread.sleep(delay);
        log("> run MouseMoveThread " + x + ", " + y);
        while (!hasFocus()) {
          Thread.sleep(1000);
        }
        int x1 = lastMouseX;
        int x2 = x;
        int y1 = lastMouseY;
        int y2 = y;
        // shrink range by 1 px on both ends
        // manually move this 1px to trip DND code
        if (x1 != x2) {
          int dx = x - lastMouseX;
          if (dx > 0) {
            x1 += 1;
            x2 -= 1;
          } else {
            x1 -= 1;
            x2 += 1;
          }
        }
        if (y1 != y2) {
          int dy = y - lastMouseY;
          if (dy > 0) {
            y1 += 1;
            y2 -= 1;
          } else {
            y1 -= 1;
            y2 += 1;
          }
        }
        robot.setAutoDelay(Math.max(duration / 100, 1));
        robot.mouseMove(x1, y1);
        int d = 100;
        for (int t = 0; t <= d; t++) {
          x1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseX, (double) x2 - lastMouseX, (double) d);
          y1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseY, (double) y2 - lastMouseY, (double) d);
          robot.mouseMove(x1, y1);
        }
        robot.mouseMove(x, y);
        lastMouseX = x;
        lastMouseY = y;
        robot.waitForIdle();
        robot.setAutoDelay(1);
      } catch (Exception e) {
        log("Bad parameters passed to mouseMove");
        e.printStackTrace();
      }

      log("< run MouseMoveThread");
    }
Ejemplo n.º 2
0
 /**
  * Reads all available cookies
  *
  * @return The complete cookie string
  */
 protected String getCookie() {
   /*
    ** get all cookies for a document
    */
   try {
     JSObject myBrowser = JSObject.getWindow(applet);
     JSObject myDocument = (JSObject) myBrowser.getMember("document");
     String myCookie = (String) myDocument.getMember("cookie");
     if (myCookie != null && myCookie.length() > 0) return myCookie;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return "?";
 }
Ejemplo n.º 3
0
 public void run() {
   try {
     if (myPreviousThread != null) myPreviousThread.join();
     Thread.sleep(delay);
     log("> run MousePressThread");
     while (!hasFocus()) {
       Thread.sleep(1000);
     }
     robot.mousePress(mask);
     robot.waitForIdle();
   } catch (Exception e) {
     log("Bad parameters passed to mousePress");
     e.printStackTrace();
   }
   log("< run MousePressThread");
 }
Ejemplo n.º 4
0
    public void run() {
      try {
        if (myPreviousThread != null) myPreviousThread.join();
        // in different order so async works
        while (!hasFocus()) {
          Thread.sleep(1000);
        }
        Thread.sleep(delay);
        log("> run KeyPressThread");

        _typeKey(charCode, keyCode, alt, ctrl, shift);
      } catch (Exception e) {
        log("Bad parameters passed to _typeKey");
        e.printStackTrace();
      }
      log("< run KeyPressThread");
    }
Ejemplo n.º 5
0
 public void run() {
   try {
     if (myPreviousThread != null) myPreviousThread.join();
     Thread.sleep(delay);
     log("> run KeyDownThread");
     while (!hasFocus()) {
       Thread.sleep(1000);
     }
     int vkCode = getVKCode(charCode, keyCode);
     if (charCode >= 32) {
       // if it is printable, then it lives in our hashmap
       KeyEvent event = (KeyEvent) charMap.get(new Integer(charCode));
       // see if we need to press shift to generate this
       // character
       if (event.isShiftDown()) {
         robot.keyPress(KeyEvent.VK_SHIFT);
         shift = true;
       }
       if (event.isAltGraphDown()) {
         robot.keyPress(KeyEvent.VK_ALT_GRAPH);
         altgraph = true;
       }
     } else {
       if (vkCode == KeyEvent.VK_ALT) {
         alt = true;
       } else if (vkCode == KeyEvent.VK_CONTROL) {
         ctrl = true;
       } else if (vkCode == KeyEvent.VK_SHIFT) {
         shift = true;
       } else if (vkCode == KeyEvent.VK_ALT_GRAPH) {
         altgraph = true;
       }
     }
     if (!isUnsafe(vkCode)) {
       robot.keyPress(vkCode);
     }
   } catch (Exception e) {
     log("Bad parameters passed to downKey");
     e.printStackTrace();
   }
   log("< run KeyDownThread");
 }
Ejemplo n.º 6
0
 public void run() {
   try {
     if (myPreviousThread != null) myPreviousThread.join();
     Thread.sleep(delay);
     log("> run MouseWheelThread " + amount);
     while (!hasFocus()) {
       Thread.sleep(1000);
     }
     int dir = 1;
     if (System.getProperty("os.name").toUpperCase().indexOf("MAC") != -1) {
       // yay for Apple
       dir = -1;
     }
     robot.setAutoDelay(Math.max(duration / Math.abs(amount), 1));
     for (int i = 0; i < Math.abs(amount); i++) {
       robot.mouseWheel(amount > 0 ? dir : -dir);
     }
     robot.setAutoDelay(1);
   } catch (Exception e) {
     log("Bad parameters passed to mouseWheel");
     e.printStackTrace();
   }
   log("< run MouseWheelThread ");
 }