Keyboard hook fixes, added targetRefresh command

Keyboard hook class now only listens for Hot Keys and not a all keys in
a global keyboard hook.  This should fix the reliability of the keyboard
hook.
Added a new command targetRefresh which will allow you to refresh the
XML on a specified window and not the entire desktop.  This will help if
you want to speed up the synthuse script by not continuously doing full
refreshes of the xml.
This commit is contained in:
Edward Jakubowski
2014-05-16 08:00:24 -04:00
parent 33522694e4
commit c36aa19753
7 changed files with 193 additions and 35 deletions

View File

@@ -7,6 +7,7 @@ import java.io.StringWriter;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.synthuse.*;
@@ -96,6 +97,48 @@ public class BaseCommand {
WIN_XML = WindowsEnumeratedXml.getXml();
LAST_UPDATED_XML = System.nanoTime();
}
public void targetXmlRefresh(String xpath) {
if (WIN_XML.isEmpty()) //can't target refresh unless there is XML to start with
{
forceXmlRefresh();
return;
}
//WIN_XML = WindowsEnumeratedXml.getXml();
LAST_UPDATED_XML = System.nanoTime();
String resultStr = "";
String resultHwndStr = "";
List<String> resultList = WindowsEnumeratedXml.evaluateXpathGetValues(WIN_XML, xpath);
for(String item: resultList) {
//System.out.println("xpath result item: " + item);
resultStr = item;
if (item.contains("hwnd=")) {
List<String> hwndList = WindowsEnumeratedXml.evaluateXpathGetValues(item, "//@hwnd");
if (hwndList.size() > 0)
resultHwndStr = hwndList.get(0).replaceAll("[^\\d-.]", ""); //get first hwnd;
}
else
resultStr = item;
break;
}
String newXml = "";
Map<String, WindowInfo> infoList;
if (resultHwndStr.contains("-")) { //uiabridge target refresh
resultHwndStr = resultHwndStr.split("-")[1];
infoList = WindowsEnumeratedXml.EnumerateWindowsWithUiaBridge(uiabridge, resultHwndStr, "*");
newXml = WindowsEnumeratedXml.generateWindowsXml(infoList, "updates");
//System.out.println("newXml: " + newXml);
}
else
{ // native target refresh
}
int pos = WIN_XML.indexOf(resultStr);
WIN_XML = WIN_XML.substring(0, pos) + newXml + WIN_XML.substring(pos + resultStr.length());
}
public String getWindowTypeWithXpath(String xpath) {
String result = "";

View File

@@ -64,6 +64,13 @@ public class MainCommands extends BaseCommand {
return true;
}
public boolean cmdTargetRefresh(String[] args) {
if (!checkArgumentLength(args, 1))
return false;
targetXmlRefresh(args[0]);
return true;
}
public boolean cmdWaitForTitle(String[] args) {
if (!checkArgumentLength(args, 1))
return false;