Added Support for Silverlight. Added more unit tests
Support for automating Silverlight in firefox and Internet Explorer is now supported, along with WPF and regular Win32.
This commit is contained in:
@@ -28,10 +28,19 @@ void WpfAutomation::setTouchableOnly(System::Boolean val)
|
|||||||
|
|
||||||
System::Windows::Automation::Condition ^ WpfAutomation::getSearchConditions()
|
System::Windows::Automation::Condition ^ WpfAutomation::getSearchConditions()
|
||||||
{
|
{
|
||||||
array<System::Windows::Automation::Condition ^> ^cons = gcnew array<System::Windows::Automation::Condition ^>(3);
|
array<System::Windows::Automation::Condition ^> ^cons = nullptr;
|
||||||
|
if (this->touchableOnly)
|
||||||
|
{
|
||||||
|
cons = gcnew array<System::Windows::Automation::Condition ^>(3);
|
||||||
cons[0] = gcnew PropertyCondition(AutomationElement::FrameworkIdProperty, this->frameworkId);//is WPF framework
|
cons[0] = gcnew PropertyCondition(AutomationElement::FrameworkIdProperty, this->frameworkId);//is WPF framework
|
||||||
cons[1] = gcnew PropertyCondition(AutomationElement::IsEnabledProperty, this->touchableOnly);//is enabled
|
cons[1] = gcnew PropertyCondition(AutomationElement::IsEnabledProperty, true);//is enabled
|
||||||
cons[2] = gcnew PropertyCondition(AutomationElement::IsOffscreenProperty, !this->touchableOnly);// is off screen
|
cons[2] = gcnew PropertyCondition(AutomationElement::IsOffscreenProperty, false);// is off screen
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cons = gcnew array<System::Windows::Automation::Condition ^>(1);
|
||||||
|
cons[0] = gcnew PropertyCondition(AutomationElement::FrameworkIdProperty, this->frameworkId);//is WPF framework
|
||||||
|
}
|
||||||
System::Windows::Automation::Condition ^result = gcnew System::Windows::Automation::AndCondition(cons);
|
System::Windows::Automation::Condition ^result = gcnew System::Windows::Automation::AndCondition(cons);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -48,11 +57,13 @@ array<System::Int32> ^ WpfAutomation::convertRuntimeIdString(System::String ^run
|
|||||||
return idArray;
|
return idArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutomationElement ^ WpfAutomation::findAutomationElementById(System::String ^runtimeIdValue)
|
AutomationElement ^ WpfAutomation::findAutomationElementById(System::String ^runtimeIdValue, System::Boolean unfiltered)
|
||||||
{
|
{
|
||||||
if (runtimeIdValue == nullptr || runtimeIdValue->Equals(L""))
|
if (runtimeIdValue == nullptr || runtimeIdValue->Equals(L""))
|
||||||
return AutomationElement::RootElement;
|
return AutomationElement::RootElement;
|
||||||
array<System::Int32> ^idArray = this->convertRuntimeIdString(runtimeIdValue);
|
array<System::Int32> ^idArray = this->convertRuntimeIdString(runtimeIdValue);
|
||||||
|
if (unfiltered)
|
||||||
|
return AutomationElement::RootElement->FindFirst(TreeScope::Descendants, gcnew PropertyCondition(AutomationElement::RuntimeIdProperty, idArray));
|
||||||
//Condition ^pcFramework = gcnew PropertyCondition(AutomationElement::FrameworkIdProperty, this->frameworkId);
|
//Condition ^pcFramework = gcnew PropertyCondition(AutomationElement::FrameworkIdProperty, this->frameworkId);
|
||||||
Condition ^pcRunId = gcnew PropertyCondition(AutomationElement::RuntimeIdProperty, idArray);
|
Condition ^pcRunId = gcnew PropertyCondition(AutomationElement::RuntimeIdProperty, idArray);
|
||||||
Condition ^frameworkAndRuntimeId = gcnew AndCondition(getSearchConditions(), pcRunId);
|
Condition ^frameworkAndRuntimeId = gcnew AndCondition(getSearchConditions(), pcRunId);
|
||||||
@@ -102,7 +113,7 @@ System::Int32 WpfAutomation::countDescendantWindows()
|
|||||||
|
|
||||||
System::Int32 WpfAutomation::countDescendantWindows(System::String ^runtimeIdValue)
|
System::Int32 WpfAutomation::countDescendantWindows(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
||||||
if (aec == nullptr)
|
if (aec == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -125,7 +136,7 @@ System::Int32 WpfAutomation::countChildrenWindows()
|
|||||||
|
|
||||||
System::Int32 WpfAutomation::countChildrenWindows(System::String ^runtimeIdValue)
|
System::Int32 WpfAutomation::countChildrenWindows(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Children, getSearchConditions());
|
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Children, getSearchConditions());
|
||||||
if (aec == nullptr)
|
if (aec == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -137,7 +148,7 @@ System::Int32 WpfAutomation::countChildrenWindows(System::String ^runtimeIdValue
|
|||||||
|
|
||||||
array<System::String ^> ^ WpfAutomation::enumChildrenWindowIds(System::String ^runtimeIdValue)
|
array<System::String ^> ^ WpfAutomation::enumChildrenWindowIds(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Children, getSearchConditions());
|
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Children, getSearchConditions());
|
||||||
if (aec == nullptr)
|
if (aec == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -146,7 +157,7 @@ array<System::String ^> ^ WpfAutomation::enumChildrenWindowIds(System::String ^r
|
|||||||
|
|
||||||
array<System::String ^> ^ WpfAutomation::enumDescendantWindowIds(System::String ^runtimeIdValue)
|
array<System::String ^> ^ WpfAutomation::enumDescendantWindowIds(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
||||||
if (aec == nullptr)
|
if (aec == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -176,7 +187,7 @@ System::String ^ WpfAutomation::getRuntimeIdFromHandle(System::IntPtr windowHand
|
|||||||
|
|
||||||
array<System::String ^> ^ WpfAutomation::enumDescendantWindowInfo(System::String ^runtimeIdValue, System::String ^properties)
|
array<System::String ^> ^ WpfAutomation::enumDescendantWindowInfo(System::String ^runtimeIdValue, System::String ^properties)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
AutomationElementCollection ^aec = parent->FindAll(TreeScope::Descendants, getSearchConditions());
|
||||||
@@ -226,6 +237,7 @@ array<System::String ^> ^ WpfAutomation::enumDescendantWindowInfo(System::String
|
|||||||
else//not runtimeId which is an Int32[]
|
else//not runtimeId which is an Int32[]
|
||||||
{
|
{
|
||||||
currentPropertyStr = currentVal->ToString();
|
currentPropertyStr = currentVal->ToString();
|
||||||
|
currentPropertyStr = currentPropertyStr->Replace(",",",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentPropertyStr->Equals(L"")) //if there isn't a value skip
|
if (currentPropertyStr->Equals(L"")) //if there isn't a value skip
|
||||||
@@ -256,7 +268,7 @@ System::String ^ WpfAutomation::getRuntimeIdFromPoint(System::Int32 x, System::I
|
|||||||
|
|
||||||
System::String ^ WpfAutomation::getParentRuntimeId(System::String ^runtimeIdValue)
|
System::String ^ WpfAutomation::getParentRuntimeId(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^target = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^target = findAutomationElementById(runtimeIdValue, true);
|
||||||
if (target == nullptr)
|
if (target == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
TreeWalker ^tw = TreeWalker::ControlViewWalker;
|
TreeWalker ^tw = TreeWalker::ControlViewWalker;
|
||||||
@@ -266,7 +278,7 @@ System::String ^ WpfAutomation::getParentRuntimeId(System::String ^runtimeIdValu
|
|||||||
|
|
||||||
System::String ^ WpfAutomation::getProperty(System::String ^propertyName, System::String ^runtimeIdValue)
|
System::String ^ WpfAutomation::getProperty(System::String ^propertyName, System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
//System::Object ^currentVal = parent->GetCurrentPropertyValue(AutomationElement::RuntimeIdProperty);
|
//System::Object ^currentVal = parent->GetCurrentPropertyValue(AutomationElement::RuntimeIdProperty);
|
||||||
@@ -286,7 +298,7 @@ System::String ^ WpfAutomation::getProperty(System::String ^propertyName, System
|
|||||||
|
|
||||||
array<System::String ^> ^ WpfAutomation::getProperties(System::String ^runtimeIdValue)
|
array<System::String ^> ^ WpfAutomation::getProperties(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
array<AutomationProperty^> ^aps = parent->GetSupportedProperties();
|
array<AutomationProperty^> ^aps = parent->GetSupportedProperties();
|
||||||
@@ -305,7 +317,7 @@ array<System::String ^> ^ WpfAutomation::getProperties(System::String ^runtimeId
|
|||||||
|
|
||||||
array<System::String ^> ^ WpfAutomation::getPropertiesAndValues(System::String ^runtimeIdValue)
|
array<System::String ^> ^ WpfAutomation::getPropertiesAndValues(System::String ^runtimeIdValue)
|
||||||
{
|
{
|
||||||
AutomationElement ^parent = findAutomationElementById(runtimeIdValue);
|
AutomationElement ^parent = findAutomationElementById(runtimeIdValue, true);
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
array<AutomationProperty^> ^aps = parent->GetSupportedProperties();
|
array<AutomationProperty^> ^aps = parent->GetSupportedProperties();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
array<System::String ^> ^ getPropertiesAndValues(System::String ^runtimeIdValue);
|
array<System::String ^> ^ getPropertiesAndValues(System::String ^runtimeIdValue);
|
||||||
private:
|
private:
|
||||||
array<System::Int32> ^ convertRuntimeIdString(System::String ^runtimeIdValue);
|
array<System::Int32> ^ convertRuntimeIdString(System::String ^runtimeIdValue);
|
||||||
System::Windows::Automation::AutomationElement ^ findAutomationElementById(System::String ^runtimeIdValue);
|
System::Windows::Automation::AutomationElement ^ findAutomationElementById(System::String ^runtimeIdValue, System::Boolean unfiltered);
|
||||||
System::String ^ getRuntimeIdFromElement(System::Windows::Automation::AutomationElement ^element);
|
System::String ^ getRuntimeIdFromElement(System::Windows::Automation::AutomationElement ^element);
|
||||||
array<System::String ^> ^ getRuntimeIdsFromCollection(System::Windows::Automation::AutomationElementCollection ^collection);
|
array<System::String ^> ^ getRuntimeIdsFromCollection(System::Windows::Automation::AutomationElementCollection ^collection);
|
||||||
System::Windows::Automation::Condition ^ getSearchConditions();
|
System::Windows::Automation::Condition ^ getSearchConditions();
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,7 @@ public class Config extends PropertiesSerializer {
|
|||||||
public static String DEFAULT_PROP_FILENAME = "synthuse.properties";
|
public static String DEFAULT_PROP_FILENAME = "synthuse.properties";
|
||||||
|
|
||||||
public String disableWpf = "false";
|
public String disableWpf = "false";
|
||||||
|
public String disableFiltersWpf = "false";
|
||||||
public String urlList = "";
|
public String urlList = "";
|
||||||
public String xpathList = "";
|
public String xpathList = "";
|
||||||
public String xpathHightlight = ".*process=\"([^\"]*)\".*";
|
public String xpathHightlight = ".*process=\"([^\"]*)\".*";
|
||||||
@@ -28,6 +29,15 @@ public class Config extends PropertiesSerializer {
|
|||||||
|
|
||||||
public boolean isWpfBridgeDisabled()
|
public boolean isWpfBridgeDisabled()
|
||||||
{
|
{
|
||||||
|
if (disableWpf == null)
|
||||||
|
return false;
|
||||||
return disableWpf.equals("true") || disableWpf.equals("True");
|
return disableWpf.equals("true") || disableWpf.equals("True");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFilterWpfDisabled()
|
||||||
|
{
|
||||||
|
if (disableFiltersWpf == null)
|
||||||
|
return false;
|
||||||
|
return disableFiltersWpf.equals("true") || disableFiltersWpf.equals("True");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import com.sun.jna.ptr.PointerByReference;
|
|||||||
|
|
||||||
public class WindowInfo {
|
public class WindowInfo {
|
||||||
|
|
||||||
public static String WPF_PROPERTY_LIST = "RuntimeIdProperty,ParentRuntimeIdProperty,ProcessIdProperty,FrameworkIdProperty,ClassNameProperty,NameProperty";
|
public static String WPF_PROPERTY_LIST = "RuntimeIdProperty,ParentRuntimeIdProperty,ProcessIdProperty,FrameworkIdProperty,ClassNameProperty,NameProperty,ValueProperty";
|
||||||
|
|
||||||
public HWND hwnd;
|
public HWND hwnd;
|
||||||
public String hwndStr = "";
|
public String hwndStr = "";
|
||||||
@@ -25,6 +25,7 @@ public class WindowInfo {
|
|||||||
public String parentStr = "";
|
public String parentStr = "";
|
||||||
public RECT rect;
|
public RECT rect;
|
||||||
public String text;
|
public String text;
|
||||||
|
public String value;
|
||||||
public String className = "";
|
public String className = "";
|
||||||
public boolean isChild = false;
|
public boolean isChild = false;
|
||||||
public String processName = "";
|
public String processName = "";
|
||||||
@@ -69,6 +70,18 @@ public class WindowInfo {
|
|||||||
hwndStr = Api.GetHandleAsString(hWnd);
|
hwndStr = Api.GetHandleAsString(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String replaceEscapedCodes(String input) {
|
||||||
|
//, is a comma ,
|
||||||
|
String result = input;
|
||||||
|
result = result.replaceAll(",", ",");
|
||||||
|
result = result.replaceAll("<", "<");
|
||||||
|
result = result.replaceAll(">", ">");
|
||||||
|
result = result.replaceAll("'", "'");
|
||||||
|
result = result.replaceAll(""", "\"");
|
||||||
|
result = result.replaceAll("&", "&");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//support for WPF and Silverlight
|
//support for WPF and Silverlight
|
||||||
public WindowInfo(String enumProperties, boolean isChild) {
|
public WindowInfo(String enumProperties, boolean isChild) {
|
||||||
//WPF_PROPERTY_LIST = "RuntimeIdProperty,ParentRuntimeIdProperty,ProcessIdProperty,FrameworkIdProperty,ClassNameProperty,NameProperty";
|
//WPF_PROPERTY_LIST = "RuntimeIdProperty,ParentRuntimeIdProperty,ProcessIdProperty,FrameworkIdProperty,ClassNameProperty,NameProperty";
|
||||||
@@ -84,9 +97,11 @@ public class WindowInfo {
|
|||||||
if (spltProperties.length > 3)
|
if (spltProperties.length > 3)
|
||||||
this.framework = spltProperties[3];
|
this.framework = spltProperties[3];
|
||||||
if (spltProperties.length > 4)
|
if (spltProperties.length > 4)
|
||||||
this.className = spltProperties[4];
|
this.className = replaceEscapedCodes(spltProperties[4]);
|
||||||
if (spltProperties.length > 5)
|
if (spltProperties.length > 5)
|
||||||
this.text = spltProperties[5];
|
this.text = replaceEscapedCodes(spltProperties[5]);
|
||||||
|
if (spltProperties.length > 6)
|
||||||
|
this.value = replaceEscapedCodes(spltProperties[6]);
|
||||||
/*
|
/*
|
||||||
this.rect = new RECT();
|
this.rect = new RECT();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
public static String getXml() {
|
public static String getXml() {
|
||||||
final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();
|
final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();
|
||||||
final Map<String, String> processList = new LinkedHashMap<String, String>();
|
final Map<String, String> processList = new LinkedHashMap<String, String>();
|
||||||
final Map<String, WindowInfo> wpfParentList = new LinkedHashMap<String, WindowInfo>();
|
final List<String> wpfParentList = new ArrayList<String>();//HwndWrapper
|
||||||
|
final List<String> silverlightParentList = new ArrayList<String>();//MicrosoftSilverlight
|
||||||
int wpfCount = 0;
|
int wpfCount = 0;
|
||||||
|
int silverlightCount = 0;
|
||||||
|
|
||||||
class ChildWindowCallback implements WinUser.WNDENUMPROC {
|
class ChildWindowCallback implements WinUser.WNDENUMPROC {
|
||||||
@Override
|
@Override
|
||||||
@@ -82,7 +84,9 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
WindowInfo wi = new WindowInfo(hWnd, true);
|
WindowInfo wi = new WindowInfo(hWnd, true);
|
||||||
infoList.put(wi.hwndStr, wi);
|
infoList.put(wi.hwndStr, wi);
|
||||||
if (wi.className.startsWith("HwndWrapper"))
|
if (wi.className.startsWith("HwndWrapper"))
|
||||||
wpfParentList.put(wi.hwndStr, null);
|
wpfParentList.add(wi.hwndStr);
|
||||||
|
if (wi.className.startsWith("MicrosoftSilverlight") || wi.className.startsWith("GeckoPluginWindow"))
|
||||||
|
silverlightParentList.add(wi.hwndStr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +97,7 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
WindowInfo wi = new WindowInfo(hWnd, false);
|
WindowInfo wi = new WindowInfo(hWnd, false);
|
||||||
infoList.put(wi.hwndStr, wi);
|
infoList.put(wi.hwndStr, wi);
|
||||||
if (wi.className.startsWith("HwndWrapper"))
|
if (wi.className.startsWith("HwndWrapper"))
|
||||||
wpfParentList.put(wi.hwndStr, null);
|
wpfParentList.add(wi.hwndStr);
|
||||||
Api.User32.instance.EnumChildWindows(hWnd, new ChildWindowCallback(), new Pointer(0));
|
Api.User32.instance.EnumChildWindows(hWnd, new ChildWindowCallback(), new Pointer(0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -103,16 +107,16 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
//Enumerate WPF windows and add to list
|
//Enumerate WPF windows and add to list
|
||||||
if (!SynthuseDlg.config.isWpfBridgeDisabled())
|
if (!SynthuseDlg.config.isWpfBridgeDisabled())
|
||||||
{
|
{
|
||||||
////win[starts-with(@class,'HwndWrapper')]
|
for (String handle : wpfParentList) {
|
||||||
//WpfBridge wb = new WpfBridge();
|
|
||||||
//if (wb.countDescendantWindows() > 0)
|
|
||||||
for (String handle : wpfParentList.keySet()) {
|
|
||||||
//WindowInfo w = wpfParentList.get(handle);
|
|
||||||
//System.out.println("EnumerateWindowsWithWpfBridge: " + handle);
|
|
||||||
Map<String, WindowInfo> wpfInfoList = EnumerateWindowsWithWpfBridge(handle, "WPF");
|
Map<String, WindowInfo> wpfInfoList = EnumerateWindowsWithWpfBridge(handle, "WPF");
|
||||||
wpfCount += wpfInfoList.size();
|
wpfCount += wpfInfoList.size();
|
||||||
infoList.putAll(wpfInfoList);
|
infoList.putAll(wpfInfoList);
|
||||||
}
|
}
|
||||||
|
for (String handle : silverlightParentList) {
|
||||||
|
Map<String, WindowInfo> slInfoList = EnumerateWindowsWithWpfBridge(handle, "Silverlight");
|
||||||
|
silverlightCount += slInfoList.size();
|
||||||
|
infoList.putAll(slInfoList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert window info list to xml dom
|
// convert window info list to xml dom
|
||||||
@@ -138,6 +142,8 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
win = doc.createElement("wpf");
|
win = doc.createElement("wpf");
|
||||||
win.setAttribute("hwnd", w.hwndStr);
|
win.setAttribute("hwnd", w.hwndStr);
|
||||||
win.setAttribute("text", w.text);
|
win.setAttribute("text", w.text);
|
||||||
|
if (w.value != "" && w.value != null)
|
||||||
|
win.setAttribute("value", w.value);
|
||||||
if (w.text != null)
|
if (w.text != null)
|
||||||
win.setAttribute("TEXT", w.text.toUpperCase());
|
win.setAttribute("TEXT", w.text.toUpperCase());
|
||||||
win.setAttribute("class", w.className);
|
win.setAttribute("class", w.className);
|
||||||
@@ -179,6 +185,7 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
totals.setAttribute("windowCount", infoList.size()+"");
|
totals.setAttribute("windowCount", infoList.size()+"");
|
||||||
totals.setAttribute("wpfWrapperCount", wpfParentList.size()+"");
|
totals.setAttribute("wpfWrapperCount", wpfParentList.size()+"");
|
||||||
totals.setAttribute("wpfCount", wpfCount+"");
|
totals.setAttribute("wpfCount", wpfCount+"");
|
||||||
|
totals.setAttribute("silverlightCount", silverlightCount+"");
|
||||||
totals.setAttribute("processCount", processList.size()+"");
|
totals.setAttribute("processCount", processList.size()+"");
|
||||||
totals.setAttribute("updatedLast", new Timestamp((new Date()).getTime()) + "");
|
totals.setAttribute("updatedLast", new Timestamp((new Date()).getTime()) + "");
|
||||||
rootElement.appendChild(totals);
|
rootElement.appendChild(totals);
|
||||||
@@ -196,6 +203,8 @@ public class WindowsEnumeratedXml implements Runnable{
|
|||||||
final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();
|
final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();
|
||||||
WpfBridge wb = new WpfBridge();
|
WpfBridge wb = new WpfBridge();
|
||||||
wb.setFrameworkId(frameworkType);
|
wb.setFrameworkId(frameworkType);
|
||||||
|
if (SynthuseDlg.config.isFilterWpfDisabled())
|
||||||
|
wb.setTouchableOnly(false);
|
||||||
long hwnd = Long.parseLong(parentHwndStr);
|
long hwnd = Long.parseLong(parentHwndStr);
|
||||||
//List<String> parentIds = new ArrayList<String>(Arrays.asList(wb.enumChildrenWindowIds("")));
|
//List<String> parentIds = new ArrayList<String>(Arrays.asList(wb.enumChildrenWindowIds("")));
|
||||||
//System.out.println("getRuntimeIdFromHandle");
|
//System.out.println("getRuntimeIdFromHandle");
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ public class WpfBridge {
|
|||||||
return getProperty("NameProperty", runtimeIdValue);
|
return getProperty("NameProperty", runtimeIdValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getWindowValue(String runtimeIdValue) {
|
||||||
|
return getProperty("ValueProperty", runtimeIdValue);
|
||||||
|
}
|
||||||
|
|
||||||
public String getWindowAutomationId(String runtimeIdValue) {
|
public String getWindowAutomationId(String runtimeIdValue) {
|
||||||
return getProperty("AutomationIdProperty", runtimeIdValue);
|
return getProperty("AutomationIdProperty", runtimeIdValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,18 +84,29 @@ public class XpathManager implements Runnable{
|
|||||||
String classStr = wpf.getWindowClass(runtimeId);
|
String classStr = wpf.getWindowClass(runtimeId);
|
||||||
//System.out.println("class: " + classStr);
|
//System.out.println("class: " + classStr);
|
||||||
String txtOrig = wpf.getWindowText(runtimeId);
|
String txtOrig = wpf.getWindowText(runtimeId);
|
||||||
|
String winValueOrig = wpf.getWindowValue(runtimeId);
|
||||||
if (classStr == null || txtOrig == null)
|
if (classStr == null || txtOrig == null)
|
||||||
return "";
|
return "";
|
||||||
//System.out.println("text: " + txtOrig);
|
//System.out.println("text: " + txtOrig);
|
||||||
String txtStr = compareLongTextString(txtOrig);
|
String txtStr = compareLongTextString(txtOrig);
|
||||||
builtXpath = "//wpf[@class='" + classStr + "' and starts-with(@text,'" + txtStr + "')]";
|
|
||||||
|
String valueStr = "";
|
||||||
|
if (winValueOrig != null)
|
||||||
|
if (!winValueOrig.isEmpty()) //if value attribute exists then use it too
|
||||||
|
valueStr = " and starts-with(@value,'" + compareLongTextString(winValueOrig) + "')";
|
||||||
|
|
||||||
|
builtXpath = "//wpf[@class='" + classStr + "' and starts-with(@text,'" + txtStr + "')" + valueStr + "]";
|
||||||
|
|
||||||
//builtXpath = "//*[@hwnd='" + runtimeId + "']";
|
//builtXpath = "//*[@hwnd='" + runtimeId + "']";
|
||||||
System.out.println("evaluateXpathGetValues: " + builtXpath);
|
//System.out.println("evaluateXpathGetValues: " + builtXpath);
|
||||||
List<String> wpfResultList = WindowsEnumeratedXml.evaluateXpathGetValues(xml, builtXpath);
|
List<String> wpfResultList = WindowsEnumeratedXml.evaluateXpathGetValues(xml, builtXpath);
|
||||||
if (wpfResultList.size() == 0)
|
if (wpfResultList.size() > 0)
|
||||||
return "";
|
|
||||||
// return builtXpath;
|
|
||||||
return builtXpath;
|
return builtXpath;
|
||||||
|
builtXpath = "//*[@hwnd='" + runtimeId + "']";
|
||||||
|
wpfResultList = WindowsEnumeratedXml.evaluateXpathGetValues(xml, builtXpath);
|
||||||
|
if (wpfResultList.size() > 0)
|
||||||
|
return builtXpath;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buildXpathStatement() {
|
public String buildXpathStatement() {
|
||||||
|
|||||||
@@ -19,41 +19,86 @@ public class WpfBridgeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void countChildren() {
|
public void countChildrenWin32() {
|
||||||
WpfBridge wb = new WpfBridge();
|
WpfBridge wb = new WpfBridge();
|
||||||
wb.setFrameworkId("Win32");//We should find some Win32 windows, maybe not WPF
|
wb.setFrameworkId("Win32");//We should find some Win32 windows, maybe not WPF
|
||||||
int win32Cnt = wb.countChildrenWindows();
|
int win32Cnt = wb.countChildrenWindows();
|
||||||
assertTrue(win32Cnt > 0);
|
|
||||||
System.out.println("win32 countChildrenWindows: " + win32Cnt);
|
System.out.println("win32 countChildrenWindows: " + win32Cnt);
|
||||||
wb.setFrameworkId("WPF");// maybe not WPF
|
assertTrue(win32Cnt > 0);
|
||||||
//System.out.println("wpf countChildrenWindows: " + wb.countChildrenWindows());
|
wb.setTouchableOnly(false);//disable filter
|
||||||
|
int ufwin32Cnt = wb.countChildrenWindows();
|
||||||
|
System.out.println("win32 unfiltered countChildrenWindows: " + ufwin32Cnt);
|
||||||
|
assertTrue(ufwin32Cnt >= win32Cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void countChildrenWpf() {
|
||||||
|
WpfBridge wb = new WpfBridge();
|
||||||
|
wb.setFrameworkId("WPF");// maybe not WPF
|
||||||
|
wb.setTouchableOnly(true);//enable filter
|
||||||
|
System.out.println("wpf countChildrenWindows: " + wb.countChildrenWindows());
|
||||||
|
wb.setTouchableOnly(false);//disable filter
|
||||||
|
System.out.println("wpf unfiltered countChildrenWindows: " + wb.countChildrenWindows());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void countDescendantsWin32() {
|
||||||
|
WpfBridge wb = new WpfBridge();
|
||||||
|
wb.setFrameworkId("Win32");//We should find some Win32 windows, maybe not WPF
|
||||||
|
int win32Cnt = wb.countDescendantWindows();
|
||||||
|
System.out.println("win32 countDescendantWindows: " + win32Cnt);
|
||||||
|
assertTrue(win32Cnt > 0);
|
||||||
|
wb.setTouchableOnly(false);//disable filter
|
||||||
|
int ufwin32Cnt = wb.countDescendantWindows();
|
||||||
|
System.out.println("win32 unfiltered countDescendantWindows: " + ufwin32Cnt);
|
||||||
|
assertTrue(ufwin32Cnt >= win32Cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void countDescendantsWpf() {
|
||||||
|
WpfBridge wb = new WpfBridge();
|
||||||
|
wb.setFrameworkId("WPF");// maybe not WPF
|
||||||
|
wb.setTouchableOnly(true);//enable filter
|
||||||
|
System.out.println("wpf countDescendantWindows: " + wb.countDescendantWindows());
|
||||||
|
wb.setTouchableOnly(false);//disable filter
|
||||||
|
System.out.println("wpf unfiltered countDescendantWindows: " + wb.countDescendantWindows());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRuntimeFromHandle() {
|
public void getRuntimeFromHandle() {
|
||||||
long handle = 1639790;
|
WpfBridge wb = new WpfBridge();
|
||||||
//String rid = wb.getRuntimeIdFromHandle(handle);
|
Api api = new Api();
|
||||||
//System.out.println("getRuntimeIdFromHandle: " + rid);
|
wb.setFrameworkId("WPF");
|
||||||
handle = 984416;
|
WinPtr wp = new WinPtr(api.user32.FindWindow(null, "MainWindow"));//find WpfMockTestApp.exe
|
||||||
//rid = wb.getRuntimeIdFromHandle(handle);
|
long handle = Long.parseLong(wp.hWndStr);
|
||||||
//System.out.println("getRuntimeIdFromHandle: " + rid);
|
String rid = wb.getRuntimeIdFromHandle(handle);
|
||||||
|
System.out.println(wp.hWndStr + " getRuntimeIdFromHandle: " + rid);
|
||||||
|
assertTrue(rid != null);
|
||||||
|
|
||||||
|
String[] props = wb.getPropertiesAndValues(rid);
|
||||||
|
assertTrue(props != null);
|
||||||
|
|
||||||
|
//for(String p : props)
|
||||||
|
// System.out.println(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enumerateWindowInfo() {
|
public void enumerateWindowInfo() {
|
||||||
WpfBridge wb = new WpfBridge();
|
WpfBridge wb = new WpfBridge();
|
||||||
/*
|
Api api = new Api();
|
||||||
EnumerateWindowsWithWpfBridge: 1639790
|
wb.setFrameworkId("WPF");
|
||||||
getRuntimeIdFromHandle
|
wb.setTouchableOnly(false);
|
||||||
runtimeId=42-1639790
|
WinPtr wp = new WinPtr(api.user32.FindWindow(null, "MainWindow"));//find WpfMockTestApp.exe
|
||||||
enumDescendantWindowIds 18
|
long handle = Long.parseLong(wp.hWndStr);
|
||||||
EnumerateWindowsWithWpfBridge: 984416
|
String rid = wb.getRuntimeIdFromHandle(handle);
|
||||||
getRuntimeIdFromHandle
|
System.out.println(wp.hWndStr + " getRuntimeIdFromHandle: " + rid);
|
||||||
runtimeId=42-984416
|
if (rid == null)
|
||||||
*/
|
return;
|
||||||
//int count = wb.countDescendantWindows("42-984416");
|
String[] wInfo = wb.enumDescendantWindowInfo(rid, WindowInfo.WPF_PROPERTY_LIST);
|
||||||
String[] wInfo = wb.enumDescendantWindowInfo("42-984416", WindowInfo.WPF_PROPERTY_LIST);
|
System.out.println("enumDescendantWindowInfo length: " + wInfo.length);
|
||||||
if (wInfo != null)
|
System.out.println(WindowInfo.WPF_PROPERTY_LIST);
|
||||||
System.out.println("enumDescendantWindowInfo: " + wInfo.length);
|
for(String w : wInfo)
|
||||||
|
System.out.println(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#
|
#
|
||||||
#Sat Apr 05 17:18:52 EDT 2014
|
#Tue Apr 08 22:36:47 EDT 2014
|
||||||
DEFAULT_PROP_FILENAME=
|
DEFAULT_PROP_FILENAME=
|
||||||
urlList=
|
urlList=
|
||||||
|
disableFiltersWpf=false
|
||||||
xpathList=
|
xpathList=
|
||||||
xpathHightlight=.*process\="([^"]*)".*
|
xpathHightlight=.*process\="([^"]*)".*
|
||||||
disableWpf=false
|
disableWpf=false
|
||||||
|
|||||||
Reference in New Issue
Block a user