This commit is contained in:
2011-02-26 14:30:14 +00:00
parent 30ebdeb7e3
commit 4c75ba5599
15 changed files with 183 additions and 119 deletions

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Scanner;
@@ -63,4 +64,12 @@ public class Native {
} catch (IOException e) {}
return null;
}
public static String replaceVariables(String string) {
Map<String, String> env = System.getenv();
for (String key : env.keySet()) {
string = string.replace(String.format("%%%s%%", key), env.get(key));
}
return string;
}
}

View File

@@ -1,18 +1,29 @@
package pm.util;
import com.eaio.nativecall.IntCall;
import com.eaio.nativecall.NativeCall;
public class Windows {
public static final int WM_COMMAND = 0x0111;
public static final int WM_APPCOMMAND = 0x0319;
public static final int MAPVK_VK_TO_VSC = 0;
public static final int WM_USER = 0x0400;
protected static IntCall findWindow;
protected static IntCall sendMessage;
protected static IntCall postMessage;
protected static IntCall mapVirtualKey;
static {
findWindow = new IntCall("user32", "FindWindowA");
sendMessage = new IntCall("user32", "SendMessageA");
postMessage = new IntCall("user32", "PostMessageA");
mapVirtualKey = new IntCall("user32", "MapVirtualKeyA");
try {
NativeCall.init();
findWindow = new IntCall("user32", "FindWindowA");
sendMessage = new IntCall("user32", "SendMessageA");
postMessage = new IntCall("user32", "PostMessageA");
mapVirtualKey = new IntCall("user32", "MapVirtualKeyA");
} catch (Exception e) {
e.printStackTrace();
}
}
public static int findWindow(String className, String windowName) {
@@ -22,4 +33,12 @@ public class Windows {
public static boolean postMessage(int handle, int message, int wParam, int lParam) {
return postMessage.executeBooleanCall(new Object[] {handle, message, wParam, lParam});
}
public static boolean sendMessage(int handle, int message, int wParam, int lParam) {
return sendMessage.executeBooleanCall(new Object[] {handle, message, wParam, lParam});
}
public static int mapVirtualKey(int code, int mapType) {
return mapVirtualKey.executeCall(new Object[] {code, 0});
}
}