Fixed highlighting around WPF and Silverlight, fixed windows commands to use WPF runtimeIds,Adding Windows Message hook feature

When targeting WPF and silverlight applications synthuse will now target
each object with a red rectangle, just like it does with native win 32
applications.
Windows commands like setfocus and such are now supported with UIA
objects like (WPF, WinForm, Silverlight).
Adding support for hooking in to the Message Queue of a target window to
see what Messages are being sent, this will allow one to possible resend
the messages back for automation purposes.  This feature is not fully
working yet, but is close.
This commit is contained in:
Edward Jakubowski
2014-05-21 08:12:11 -04:00
parent c36aa19753
commit 1721d2a130
51 changed files with 2282 additions and 125 deletions

View File

@@ -6,11 +6,14 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.synthuse.*;
import com.sun.jna.platform.win32.WinDef.HWND;
public class BaseCommand {
static String WIN_XML = "";
@@ -132,7 +135,14 @@ public class BaseCommand {
}
else
{ // native target refresh
infoList = new LinkedHashMap<String, WindowInfo>();
HWND parentHwnd = Api.GetHandleFromString(resultHwndStr);
WindowInfo wi = new WindowInfo(parentHwnd, false);
infoList.put(wi.hwndStr, wi);
infoList.putAll(WindowsEnumeratedXml.EnumerateWin32ChildWindows(parentHwnd));
//WindowsEnumeratedXml.appendUiaBridgeWindows(infoList); //if we need this we should specify a runtimeID handle instead
newXml = WindowsEnumeratedXml.generateWindowsXml(infoList, "updates");
System.out.println("newNativeXml: " + newXml);
}
int pos = WIN_XML.indexOf(resultStr);

View File

@@ -18,9 +18,9 @@ public class MouseCommands extends BaseCommand {
if (handle.isEmpty())
return false;
String wtype = getWindowTypeWithXpath(args[0]);
//System.out.println("wtype: " + wtype + " hwnd " + handle.hWnd + " hmenu " + handle.hmenuStr + " pos " + handle.hmenuPos);
System.out.println("wtype: " + wtype + " hwnd " + handle.hWnd + " hmenu " + handle.hmenuStr + " pos " + handle.hmenuPos);
Point p = getCenterWindowPosition(handle, wtype);
//System.out.println("cmdClick: " + p.x + "," + p.y);
System.out.println("cmdClick: " + p.x + "," + p.y);
RobotMacro.mouseMove(p.x + parentProcessor.targetOffset.x, p.y + parentProcessor.targetOffset.y);
RobotMacro.leftClickMouse();
return true;

View File

@@ -17,6 +17,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.activateWindow(handle.hWnd);
//api.showWindow(handle);
return true;
@@ -28,6 +29,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.minimizeWindow(handle.hWnd);
return true;
}
@@ -38,6 +40,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.maximizeWindow(handle.hWnd);
return true;
}
@@ -48,6 +51,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.restoreWindow(handle.hWnd);
return true;
}
@@ -58,6 +62,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.hideWindow(handle.hWnd);
return true;
}
@@ -68,6 +73,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.showWindow(handle.hWnd);
return true;
}
@@ -78,6 +84,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.switchToThisWindow(handle.hWnd, true);
return true;
}
@@ -89,6 +96,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.closeWindow(handle.hWnd);
return true;
}
@@ -99,6 +107,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return false;
handle.convertToNativeHwnd();
api.sendWmSetText(handle.hWnd, args[1]);
return true;
}
@@ -109,6 +118,7 @@ public class WindowsCommands extends BaseCommand {
WinPtr handle = findHandleWithXpath(args[0]);
if (handle.isEmpty())
return "";
handle.convertToNativeHwnd();
return api.sendWmGetText(handle.hWnd);
}
@@ -119,6 +129,7 @@ public class WindowsCommands extends BaseCommand {
if (handle.isEmpty())
return false;
int id = findMenuIdWithXpath(args[0]);
handle.convertToNativeHwnd();
//LRESULT result =
//System.out.println("PostMessage to " + handle.hWndStr + " for id " + id);
api.user32.PostMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));
@@ -133,6 +144,7 @@ public class WindowsCommands extends BaseCommand {
if (handle.isEmpty())
return false;
int id = Integer.parseInt(args[1]); //context menu id is supplied as second argument
handle.convertToNativeHwnd();
//LRESULT result =
System.out.println("PostMessage to " + handle.toString() + " for id " + id + " - " + Api.MAKELONG(id, 0));
//api.user32.PostMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));