[sikuli] 233/385: made the local keyboard setup runnable (at least the preparation function)
Gilles Filippini
pini at moszumanska.debian.org
Sun Jun 29 19:26:17 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 afb81140db0035335ab529c3a626d7b7ff83391d
Author: Raimund Hocke <info at its-me-raiman.de>
Date: Wed Feb 19 18:29:57 2014 +0100
made the local keyboard setup runnable (at least the preparation function)
---
API/src/main/java/org/sikuli/script/Key.java | 80 ++++++++++-----------
.../src/main/java/org/sikuli/basics/RunSetup.java | 31 +++++++-
.../src/main/java/org/sikuli/basics/SikuliX.java | 18 +++--
Basics/src/main/resources/Images/SikuliLogo.png | Bin 0 -> 8578 bytes
4 files changed, 83 insertions(+), 46 deletions(-)
diff --git a/API/src/main/java/org/sikuli/script/Key.java b/API/src/main/java/org/sikuli/script/Key.java
index 9b2846d..13d9aba 100755
--- a/API/src/main/java/org/sikuli/script/Key.java
+++ b/API/src/main/java/org/sikuli/script/Key.java
@@ -214,11 +214,11 @@ public class Key {
"VK_Z","90"
//</editor-fold>
};
-
+
// non function keys on US-Keyboard per line top down without modifier keys
- public static String keyboardUS =
+ public static String keyboardUS =
"1234567890-=" + "qwertyuiop[]" + "asdfghjkl;'\\" + "`zxcvbnm,./";
-
+
//<editor-fold defaultstate="collapsed" desc="KeyNames to UniCode (used in type() with Key.XXX)">
public static final String SPACE = " ";
public static final String ENTER = "\n";
@@ -336,7 +336,7 @@ public class Key {
public static final char C_CONTEXT = '\ue041'; // VK_CONTEXT_MENU
public static final String NEXT = "\ue043";
public static final char C_NEXT = '\ue043'; // VK_CONTEXT_MENU
-
+
public static final char cMax = '\ue050';
public static final char cMin = '\ue000';
public static int keyMaxLength;
@@ -391,12 +391,12 @@ public class Key {
}
//</editor-fold>
}
-
+
//<editor-fold defaultstate="collapsed" desc="support functions for write()">
public static String getTextFromKeycode(int key) {
return keys.get(key);
}
-
+
public static boolean isRepeatable(String token) {
int key = toJavaKeyCodeFromText(token);
switch (key) {
@@ -411,7 +411,7 @@ public class Key {
}
return false;
}
-
+
public static boolean isModifier(String token) {
if (toJavaKeyCodeFromText(token) == toJavaKeyCodeFromText("#S.") ||
toJavaKeyCodeFromText(token) == toJavaKeyCodeFromText("#C.") ||
@@ -421,7 +421,7 @@ public class Key {
}
return false;
}
-
+
public static int toJavaKeyCodeFromText(String key) {
if (null == keyTexts.get(key)) {
return -1;
@@ -430,7 +430,7 @@ public class Key {
}
}
//</editor-fold>
-
+
/**
* Convert Sikuli Key to Java virtual key code
*/
@@ -693,7 +693,7 @@ public class Key {
case Key.C_DIVIDE: return "#NDIV.";
case Key.C_DECIMAL: return "#NDEC.";
case Key.C_CONTEXT: return "#NCON.";
-//KeyModifiers
+//KeyModifiers
case Key.C_SHIFT: return "#SHIFT.";
case Key.C_CTRL: return "#CTRL.";
case Key.C_ALT: return "#ALT.";
@@ -703,7 +703,7 @@ public class Key {
return "" + key;
}
}
-
+
protected static int convertModifiers(String mod) {
int modNew = 0;
char key;
@@ -755,10 +755,10 @@ public class Key {
return KeyEvent.VK_CONTROL;
}
}
-
+
//<editor-fold defaultstate="collapsed" desc="keyboard setup - INTERNAL USE ONLY">
static String[] result = new String[] {""};
-
+
/**
* INTERNAL USE ONLY
* create an alternate keycode table for a non-US keyboard
@@ -769,7 +769,7 @@ public class Key {
String keysx = Key.keyboardUS;
Screen s = new Screen(0);
- ImagePath.add("org.sikuli.script.SikuliX/images");
+ ImagePath.add("org.sikuli.basics.SikuliX/Images");
ShowKeyBoardSetupWindow win = new ShowKeyBoardSetupWindow();
win.start();
@@ -780,6 +780,7 @@ public class Key {
s.click(txtArea);
s.wait(1.0F);
String[] mods = new String[]{"", "S", "A", "SA"};
+ Debug.setDebugLevel(0);
for (String modx : mods) {
s.paste((modx.isEmpty() ? "NO" : modx) + " modifier" + "\n");
if (!modx.isEmpty()) {
@@ -804,9 +805,14 @@ public class Key {
s.paste("\n");
s.type(Key.ENTER);
}
+ Debug.setDebugLevel(3);
s.click(btnOK);
while (true) {
- s.wait(1.0F);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ }
+ Debug.log(3, "waiting for result\n" + result[0]);
if (!result[0].isEmpty()) {
break;
}
@@ -815,15 +821,14 @@ public class Key {
String keysNew;
String mod;
int nKDE = 0;
- for (int n = 0; n < keyNewx.length; n++) {
+ for (int n = 0; n < keyNewx.length; n += 6) {
mod = keyNewx[n].substring(0, 2);
keysNew = keyNewx[n + 1] + keyNewx[n + 2] + keyNewx[n + 3] + keyNewx[n + 4];
keyXX[nKDE] = mod + ": " + keysNew;
- //System.out.println(keyXX[nKDE]);
- n += 4;
+ Debug.log(3, "%s", keyXX[nKDE]);
nKDE++;
}
- String kSet;
+ String kSet;
int offset = 4;
char keyOld, keyNew;
int[] codeA;
@@ -841,7 +846,7 @@ public class Key {
} else if ("SA".equals(mod)) {
modText = "SHIFT ALT ";
}
- //System.out.println(mod + "\n" + kSet);
+ Debug.log(3, mod + "\n" + kSet);
nOld = 0;
for (int i = 0; i < kSet.length(); i++) {
if (!" ".equals("" + kSet.charAt(i + 3))) {
@@ -881,21 +886,21 @@ public class Key {
if (keyLocal.get(keyNew) == null) {
keyLocal.put(keyNew, codeI);
}
- //System.out.println(String.format("%s %c %c %s", mod, keyOld, keyNew, codeS));
+ Debug.log(3,"%s %c %c %s", mod, keyOld, keyNew, codeS);
i += offset - 1;
offset = 4;
nOld += 1;
}
}
-
- System.out.println("--------------- keyLocal");
+
+ Debug.log(3,"--------------- keyLocal");
Integer[] codeI;
for (Character kc : keyLocal.keySet()) {
codeI = keyLocal.get(kc);
- System.out.println(String.format("%c %s %s %s", kc.charValue(),
+ Debug.log(3,"%c %s %s %s", kc.charValue(),
(codeI[0] == -1 ? "" : KeyEvent.getKeyText(codeI[0])),
(codeI[1] == -1 ? "" : KeyEvent.getKeyText(codeI[1])),
- (codeI[2] == -1 ? "" : KeyEvent.getKeyText(codeI[2])) ));
+ (codeI[2] == -1 ? "" : KeyEvent.getKeyText(codeI[2])) );
}
}
@@ -910,11 +915,11 @@ public class Key {
}
return ret;
}
-
+
static class ShowKeyBoardSetupWindow extends Thread {
-
+
JFrame kbSetup;
-
+
@Override
public void run() {
kbSetup = new JFrame("Localized Keyboard Setup");
@@ -928,13 +933,8 @@ public class Key {
win.setLogo(new ImageIcon(Image.create("SikuliLogo").get()));
kbSetup.setVisible(true);
}
-
- public void setResult(String text) {
- kbSetup.setVisible(false);
- result[0] = text;
- }
}
-
+
/**
* INTERNAL USE ONLY
* create a table containing all relevant key, keycode and keytext settings for VK_xxx
@@ -944,7 +944,7 @@ public class Key {
for (int i = 0; i < keyVK.length; i += 2) {
namesVK.put(keyVK[i+1], keyVK[i].substring(3));
}
-
+
String keyText;
int upper = 66000;
String form = "%05d: %-25s %-20s %-15s %15s %s";
@@ -972,7 +972,7 @@ public class Key {
if (key < 32) {
key = ' ';
}
- System.out.println(String.format(form, key, keyText, "...", "...", k2, k1));
+ Debug.log(3, form, key, keyText, "...", "...", k2, k1);
}
continue;
}
@@ -982,11 +982,11 @@ public class Key {
vkey = "...";
}
if (null == getTextFromKeycode(key)) {
- System.out.println(String.format(form, key, keyText.toUpperCase(),
- vkey, "...", k2, k1));
+ Debug.log(3, form, key, keyText.toUpperCase(),
+ vkey, "...", k2, k1);
} else {
- System.out.println(String.format(form, key, keyText.toUpperCase(),
- vkey, getTextFromKeycode(key), k2, k1));
+ Debug.log(3, form, key, keyText.toUpperCase(),
+ vkey, getTextFromKeycode(key), k2, k1);
}
}
}
diff --git a/Basics/src/main/java/org/sikuli/basics/RunSetup.java b/Basics/src/main/java/org/sikuli/basics/RunSetup.java
index 1b6620c..d872708 100644
--- a/Basics/src/main/java/org/sikuli/basics/RunSetup.java
+++ b/Basics/src/main/java/org/sikuli/basics/RunSetup.java
@@ -79,7 +79,7 @@ public class RunSetup {
private static boolean runningSetup = false;
private static boolean generallyDoUpdate = false;
public static String timestampBuilt;
- private static final String tsb = "##--##Tue Jan 21 15:52:52 CET 2014##--##";
+ private static final String tsb = "##--##Mi 19 Feb 2014 16:41:13 CET##--##";
static {
timestampBuilt = SikuliX.makeTimestamp(tsb);
@@ -168,7 +168,34 @@ public class RunSetup {
options.remove(0);
}
- runningJar = FileManager.getJarName();
+ if (args.length == 1 && "keyboardsetup".equals(args[0].toLowerCase())) {
+ String dir = System.getProperty("user.dir");
+ String jar = "sikulixapi.jar";
+ File jf = new File(dir, jar);
+ if (jf.exists()) {
+ SikuliX.addToClasspath(jf.getAbsolutePath());
+ jf = null;
+ }
+ if (jf != null) {
+ jar = "sikulix.jar";
+ jf = new File(dir, jar);
+ if (jf.exists()) {
+ SikuliX.addToClasspath(jf.getAbsolutePath());
+ jf = null;
+ }
+ }
+ if (jf != null) {
+ Debug.error("no suitable jar found");
+ System.exit(1);
+ }
+ Settings.ActionLogs = false;
+ Settings.InfoLogs = false;
+ Debug.setDebugLevel(3);
+ SikuliX.callKeyBoardSetup();
+ System.exit(0);
+ }
+
+ runningJar = FileManager.getJarName();
if (runningJar.isEmpty()) {
popError("error accessing jar - terminating");
System.exit(1);
diff --git a/Basics/src/main/java/org/sikuli/basics/SikuliX.java b/Basics/src/main/java/org/sikuli/basics/SikuliX.java
index 0ba6ef6..3830f5a 100644
--- a/Basics/src/main/java/org/sikuli/basics/SikuliX.java
+++ b/Basics/src/main/java/org/sikuli/basics/SikuliX.java
@@ -56,7 +56,7 @@ public class SikuliX {
private static final String ScriptSikuliXCL = "org.sikuli.script.SikuliX";
private static final String ScriptKeyCL = "org.sikuli.script.Key";
private static Class ScriptCl, KeyCl;
- private static Method endWhat, toJavaKeyCode, setBundlePath;
+ private static Method endWhat, keyBoardSetup, setBundlePath;
private static boolean runningSetup = false;
private static boolean runningFromJar;
private static String jarPath;
@@ -148,15 +148,25 @@ public class SikuliX {
public static int[] callKeyToJavaKeyCodeMethod(String key) {
try {
KeyCl = Class.forName(ScriptKeyCL);
- toJavaKeyCode = KeyCl.getMethod("toJavaKeyCode", new Class[]{String.class});
- return (int[]) toJavaKeyCode.invoke(KeyCl, new Object[]{key});
+ keyBoardSetup = KeyCl.getMethod("toJavaKeyCode", new Class[]{String.class});
+ return (int[]) keyBoardSetup.invoke(KeyCl, new Object[]{key});
} catch (Exception ex) {
Debug.error("Invoke KeyToJavaKeyCodeMethod: Fatal Error 999: could not be run!");
return null;
}
}
- public static void callImagePathSetBundlePath(String path) {
+ public static void callKeyBoardSetup() {
+ try {
+ KeyCl = Class.forName(ScriptKeyCL);
+ keyBoardSetup = KeyCl.getMethod("keyBoardSetup", new Class[]{});
+ keyBoardSetup.invoke(KeyCl, new Object[]{});
+ } catch (Exception ex) {
+ Debug.error("Invoke Key.keyBoardSetup: Fatal Error 999: could not be run!");
+ }
+ }
+
+ public static void callImagePathSetBundlePath(String path) {
try {
ScriptCl = Class.forName("org.sikuli.script.ImagePath");
setBundlePath = ScriptCl.getMethod("setBundlePath", new Class[]{String.class});
diff --git a/Basics/src/main/resources/Images/SikuliLogo.png b/Basics/src/main/resources/Images/SikuliLogo.png
new file mode 100644
index 0000000..960f35a
Binary files /dev/null and b/Basics/src/main/resources/Images/SikuliLogo.png differ
--
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