[sikuli] 375/385: added a function to detect mouse move since last mouse action

Gilles Filippini pini at moszumanska.debian.org
Sun Jun 29 19:26:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

pini pushed a commit to tag upstream/1.1.0_beta1
in repository sikuli.

commit 4f3c1639c03664721a84886fdb5fdc1e960a278e
Author: Raimund Hocke <rmhdevelop at me.com>
Date:   Tue Apr 29 11:18:16 2014 +0200

    added a function to detect mouse move since last mouse action
---
 API/src/main/java/org/sikuli/script/Key.java   | 9 ++++++++-
 API/src/main/java/org/sikuli/script/Mouse.java | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/API/src/main/java/org/sikuli/script/Key.java b/API/src/main/java/org/sikuli/script/Key.java
index 13f35d6..d50f460 100755
--- a/API/src/main/java/org/sikuli/script/Key.java
+++ b/API/src/main/java/org/sikuli/script/Key.java
@@ -784,7 +784,7 @@ public class Key {
     s.wait(3.0F);
 
     Location btnOK = s.find("SikuliLogo").getCenter();
-    Location txtArea = btnOK.offset(0, 200);
+    Location txtArea = btnOK.offset(0, 400);
     s.click(txtArea);
     s.wait(1.0F);
     String[] mods = new String[]{"", "S", "A", "SA"};
@@ -805,6 +805,10 @@ public class Key {
         c = "" + keysx.charAt(n);
         s.paste(c);
         s.type(" ");
+        if (Mouse.hasMoved()) {
+          s.click(txtArea);
+          s.wait(0.3F);
+        }
         s.write(String.format("%s%s ", modx, c));
         if ("=".equals(c) || "]".equals(c) || "\\".equals(c)) {
           s.paste("\n");
@@ -857,6 +861,9 @@ public class Key {
       Debug.log(3, mod + "\n" + kSet);
       nOld = 0;
       for (int i = 0; i < kSet.length(); i++) {
+        if (i + 3 > kSet.length()) {
+          break;
+        }
         if (!" ".equals("" + kSet.charAt(i + 3))) {
           offset = 3;
         }
diff --git a/API/src/main/java/org/sikuli/script/Mouse.java b/API/src/main/java/org/sikuli/script/Mouse.java
index 1d76cb0..19e9aea 100644
--- a/API/src/main/java/org/sikuli/script/Mouse.java
+++ b/API/src/main/java/org/sikuli/script/Mouse.java
@@ -280,6 +280,14 @@ public class Mouse {
       }
     }
   }
+  
+  public static boolean hasMoved() {
+    Point pos = MouseInfo.getPointerInfo().getLocation();
+    if (Mouse.get().lastPos.x != pos.x || Mouse.get().lastPos.y != pos.y) {
+      return true;
+    }
+    return false;
+  }
 
   private void showMousePos(Point pos) {
     Location lPos = new Location(pos);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/sikuli.git



More information about the pkg-java-commits mailing list