Extended Msg hook text limit, msg hook prompts before switching between 32 and 64 bits, optionally disable uiabridge's caches
Message Hook Viewer text limit is not set to 700,000 characters, allowing it to show many more messages/lines Message Hook Viewer will prompt user if the want to switch between 64 and 32 bits. UiaBridge has an optional flag to disable cache. This fixes an issue where caching is either slower or causes issues when using multiple threads in OASIS.
This commit is contained in:
@@ -81,6 +81,8 @@ public class KeyboardHook implements Runnable{
|
||||
public static HHOOK hHook = null;
|
||||
public static LowLevelKeyboardProc lpfn;
|
||||
public static volatile boolean quit = false;
|
||||
|
||||
private static Thread khThread = null;
|
||||
|
||||
|
||||
public interface User32Ex extends W32APIOptions {
|
||||
@@ -199,6 +201,14 @@ public class KeyboardHook implements Runnable{
|
||||
//stops Keyboard hook and causes the unhook command to be called
|
||||
public static void stopKeyboardHook() {
|
||||
quit = true;
|
||||
if (khThread != null)
|
||||
{
|
||||
try {
|
||||
khThread.join();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// search target keyboard event list for a match and return it otherwise return null if no match
|
||||
@@ -228,14 +238,27 @@ public class KeyboardHook implements Runnable{
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
// clear all target keys to watch for
|
||||
public static void clearKeyEvent() {
|
||||
KeyboardHook.targetList.clear();
|
||||
}
|
||||
|
||||
|
||||
// add more target keys to watch for
|
||||
public static void addKeyEvent(int targetKeyCode, boolean withShift, boolean withCtrl, boolean withAlt) {
|
||||
KeyboardHook.targetList.add(new TargetKeyPress(KeyboardHook.targetList.size() + 1 , targetKeyCode, withShift, withCtrl, withAlt));
|
||||
}
|
||||
|
||||
// add more target keys to watch for
|
||||
public static void addKeyEvent(int targetKeyCode) {
|
||||
KeyboardHook.targetList.add(new TargetKeyPress(targetKeyCode));
|
||||
}
|
||||
|
||||
|
||||
private void registerAllHotKeys() // must register hot keys in the same thread that is watching for hotkey messages
|
||||
{
|
||||
//System.out.println("registering hotkeys");
|
||||
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||
//BOOL WINAPI RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk);
|
||||
int modifiers = User32.MOD_NOREPEAT;
|
||||
@@ -256,6 +279,7 @@ public class KeyboardHook implements Runnable{
|
||||
|
||||
private void unregisterAllHotKeys() // must register hot keys in the same thread that is watching for hotkey messages
|
||||
{
|
||||
//System.out.println("unregistering hotkeys");
|
||||
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||
if (!User32.INSTANCE.UnregisterHotKey(Pointer.NULL, tkp.idNumber))
|
||||
{
|
||||
@@ -263,12 +287,6 @@ public class KeyboardHook implements Runnable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add more target keys to watch for
|
||||
public static void addKeyEvent(int targetKeyCode) {
|
||||
KeyboardHook.targetList.add(new TargetKeyPress(targetKeyCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -286,8 +304,9 @@ public class KeyboardHook implements Runnable{
|
||||
}
|
||||
|
||||
public static void StartKeyboardHookThreaded(KeyboardEvents events) {
|
||||
Thread t = new Thread(new KeyboardHook(events));
|
||||
t.start();
|
||||
quit = false;
|
||||
khThread = new Thread(new KeyboardHook(events));
|
||||
khThread.start();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SynthuseDlg extends JFrame {
|
||||
//private MessageHookFrame msgHook = null;
|
||||
private int targetX;
|
||||
private int targetY;
|
||||
private UiaBridge uiabridge = new UiaBridge();
|
||||
private UiaBridge uiabridge = null;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
@@ -296,7 +296,7 @@ public class SynthuseDlg extends JFrame {
|
||||
|
||||
btnFind = new JButton("Find");
|
||||
btnFind.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
String xpathItem = cmbXpath.getSelectedItem().toString();
|
||||
int matches = XpathManager.nextXpathMatch(xpathItem, textPane, lblStatus, false);
|
||||
if (matches < 0) //check for an error
|
||||
@@ -427,43 +427,18 @@ public class SynthuseDlg extends JFrame {
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent arg0) {
|
||||
//System.out.println("synthuse window closed");
|
||||
KeyboardHook.stopKeyboardHook(); //stop keyboard hook
|
||||
config.save();
|
||||
SynthuseDlg.this.dispose(); // force app to close
|
||||
}
|
||||
});
|
||||
|
||||
KeyboardHook.addKeyEvent(config.getRefreshKeyCode(), true, true, false);// refresh xml when CTRL+SHIFT+3 is pressed
|
||||
KeyboardHook.addKeyEvent(config.getTargetKeyCode(), true, true, false);// target window when CTRL+SHIFT+~ is pressed
|
||||
//add global hook and event
|
||||
KeyboardHook.StartKeyboardHookThreaded(new KeyboardHook.KeyboardEvents() {
|
||||
@Override
|
||||
public void keyPressed(KeyboardHook.TargetKeyPress target) {
|
||||
//System.out.println("target key pressed " + target.targetKeyCode);
|
||||
if (target.targetKeyCode == config.getRefreshKeyCode()){
|
||||
SwingUtilities.invokeLater(new Runnable() {//swing components are not thread safe, this will run on Swings event dispatch thread
|
||||
public void run() {
|
||||
btnRefresh.doClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (target.targetKeyCode == config.getTargetKeyCode()){
|
||||
SwingUtilities.invokeLater(new Runnable() {//swing components are not thread safe, this will run on Swings event dispatch thread
|
||||
public void run() {
|
||||
//if (!SynthuseDlg.config.isUiaBridgeDisabled())
|
||||
// uiabridge.initialize("");//need to re-initialize because it might be in a different thread.
|
||||
Point p = Api.getCursorPos();
|
||||
targetX = p.x;
|
||||
targetY = p.y;
|
||||
targetDragged();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
initializeHotKeys();
|
||||
|
||||
btnRefresh.doClick();
|
||||
//uiabridge = new UiaBridge();
|
||||
//uiabridge.useCachedRequests(false);
|
||||
refreshDatabinding();
|
||||
super.setAlwaysOnTop(config.isAlwaysOnTop());
|
||||
}
|
||||
@@ -497,7 +472,7 @@ public class SynthuseDlg extends JFrame {
|
||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
|
||||
this.setVisible(true);
|
||||
return dialogResult;
|
||||
return dialogResult;// this gets returned immediately
|
||||
}
|
||||
|
||||
public void refreshDatabinding() {
|
||||
@@ -507,6 +482,40 @@ public class SynthuseDlg extends JFrame {
|
||||
XmlEditorKit.TAG_HIGHLIGHTED = config.xpathHightlight;
|
||||
}
|
||||
|
||||
private void initializeHotKeys()
|
||||
{
|
||||
KeyboardHook.clearKeyEvent();
|
||||
KeyboardHook.addKeyEvent(config.getRefreshKeyCode(), true, true, false);// refresh xml when CTRL+SHIFT+3 is pressed
|
||||
KeyboardHook.addKeyEvent(config.getTargetKeyCode(), true, true, false);// target window when CTRL+SHIFT+~ is pressed
|
||||
//add global hook and event
|
||||
KeyboardHook.StartKeyboardHookThreaded(new KeyboardHook.KeyboardEvents() {
|
||||
@Override
|
||||
public void keyPressed(KeyboardHook.TargetKeyPress target) {
|
||||
//System.out.println("target key pressed " + target.targetKeyCode);
|
||||
if (target.targetKeyCode == config.getRefreshKeyCode()){
|
||||
SwingUtilities.invokeLater(new Runnable() {//swing components are not thread safe, this will run on Swings event dispatch thread
|
||||
public void run() {
|
||||
btnRefresh.doClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (target.targetKeyCode == config.getTargetKeyCode()){
|
||||
SwingUtilities.invokeLater(new Runnable() {//swing components are not thread safe, this will run on Swings event dispatch thread
|
||||
public void run() {
|
||||
//if (!SynthuseDlg.config.isUiaBridgeDisabled())
|
||||
// uiabridge.initialize("");//need to re-initialize because it might be in a different thread.
|
||||
Point p = Api.getCursorPos();
|
||||
targetX = p.x;
|
||||
targetY = p.y;
|
||||
targetDragged();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void targetDragged() {
|
||||
HWND hwnd = Api.getWindowFromCursorPos();//new Point(targetX,targetY)
|
||||
String handleStr = Api.GetHandleAsString(hwnd);
|
||||
@@ -518,7 +527,13 @@ public class SynthuseDlg extends JFrame {
|
||||
|
||||
String enumProperties = "";
|
||||
if (!SynthuseDlg.config.isUiaBridgeDisabled())
|
||||
{
|
||||
//System.out.println("useCachedRequests false");
|
||||
if (uiabridge == null)
|
||||
uiabridge = new UiaBridge();
|
||||
uiabridge.useCachedRequests(false);
|
||||
enumProperties = uiabridge.getWindowInfo(targetX, targetY, WindowInfo.UIA_PROPERTY_LIST_ADV);
|
||||
}
|
||||
String runtimeId = WindowInfo.getRuntimeIdFromProperties(enumProperties);
|
||||
String framework = WindowInfo.getFrameworkFromProperties(enumProperties);
|
||||
Rectangle rect = UiaBridge.getBoundaryRect(enumProperties);
|
||||
|
||||
@@ -103,6 +103,7 @@ public class UiaBridge {
|
||||
|
||||
public native void initialize(String properties);
|
||||
public native void shutdown();
|
||||
public native void useCachedRequests(boolean cacheRequestsFlg);
|
||||
public native int addEnumFilter(String propertyName, String propertyValue);
|
||||
public native void clearEnumFilters();
|
||||
public native String[] enumWindowInfo(String properties);
|
||||
@@ -169,10 +170,12 @@ public class UiaBridge {
|
||||
{
|
||||
String[] boundarySplt = replaceEscapedCodes(propSplt[propSplt.length - 1]).split(",");
|
||||
if (boundarySplt.length == 4 )
|
||||
rect.x = Integer.parseInt(boundarySplt[0]);
|
||||
rect.y = Integer.parseInt(boundarySplt[1]);
|
||||
rect.width = Integer.parseInt(boundarySplt[2]);
|
||||
rect.height = Integer.parseInt(boundarySplt[3]);
|
||||
{
|
||||
rect.x = Integer.parseInt(boundarySplt[0]);
|
||||
rect.y = Integer.parseInt(boundarySplt[1]);
|
||||
rect.width = Integer.parseInt(boundarySplt[2]);
|
||||
rect.height = Integer.parseInt(boundarySplt[3]);
|
||||
}
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user