ext/UiaDll/UiaDll/ElementMethods.cpp in uia-0.1.3.1 vs ext/UiaDll/UiaDll/ElementMethods.cpp in uia-0.2
- old
+ new
@@ -2,62 +2,87 @@
#include "ConditionHelper.h"
using namespace UIA::Helper;
extern "C" {
- Element^ Find(ElementInformationPtr element) {
+ Element^ ElementFrom(ElementInformationPtr element) {
if( element->nativeWindowHandle > 0 ) {
return Element::ByHandle(IntPtr(element->nativeWindowHandle));
}
- return Element::ByRuntimeId(ArrayHelper::ToArray(element->runtimeId, element->runtimeIdLength));
- }
-
+ return Element::ByRuntimeId(ArrayHelper::ToArray(element->runtimeId, element->runtimeIdLength));
+}
__declspec(dllexport) void Element_Release(ElementInformationPtr elementInformation) {
delete elementInformation;
}
__declspec(dllexport) void Element_Refresh(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
try {
- element->Refresh(Find(element));
+ element->Refresh(ElementFrom(element));
} catch(Exception^ e) {
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
}
}
__declspec(dllexport) void Element_SendKeys(ElementInformationPtr element, const char* keysToSend, char* errorInfo, const int errorInfoLength) {
try {
- Find(element)->SendKeys(gcnew String(keysToSend));
+ ElementFrom(element)->SendKeys(gcnew String(keysToSend));
} catch(Exception^ e) {
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
}
}
- ElementInformationPtr ManagedFindByConditions(ElementInformationPtr element, const char* treeScope, list<SearchConditionPtr>& conditions, char* errorInfo, const int errorInfoLength) {
+ ElementInformationPtr ManagedFindFirst(ElementInformationPtr element, const char* treeScope, list<SearchConditionPtr>& conditions, char* errorInfo, const int errorInfoLength) {
try {
auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope));
- return ElementInformation::From(Find(element)->ChildWith(scope, ConditionHelper::ConditionFrom(conditions)));
+ return ElementInformation::From(ElementFrom(element)->FindFirst(scope, ConditionHelper::ConditionFrom(conditions)));
} catch(Exception^ e) {
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
}
return NULL;
}
- __declspec(dllexport) ElementInformationPtr FindByConditions(ElementInformationPtr element, const char* treeScope, char* errorInfo, const int errorInfoLength, const int count, SearchConditionPtr arg0, ...) {
+ __declspec(dllexport) ElementInformationPtr FindFirst(ElementInformationPtr element, const char* treeScope, char* errorInfo, const int errorInfoLength, const int count, SearchConditionPtr arg0, ...) {
va_list arguments;
va_start(arguments, arg0);
list<SearchConditionPtr> conditions;
conditions.push_back(arg0);
for(auto index = 1; index < count; index++) {
conditions.push_back(va_arg(arguments, SearchConditionPtr));
}
- return ManagedFindByConditions(element, treeScope, conditions, errorInfo, errorInfoLength);
+ return ManagedFindFirst(element, treeScope, conditions, errorInfo, errorInfoLength);
}
+ int ManagedFindAll(ElementInformationPtr element, ElementInformation** elements, const char* treeScope, list<SearchConditionPtr>& conditions, char* errorInfo, const int errorInfoLength) {
+ try {
+ auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope));
+ auto foundElements = ElementFrom(element)->Find(scope, ConditionHelper::ConditionFrom(conditions));
+ *elements = ElementInformation::From(foundElements);
+ return foundElements->Length;
+ } catch(Exception^ e) {
+ StringHelper::CopyToUnmanagedString(e->Message + Environment::NewLine + e->StackTrace, errorInfo, errorInfoLength);
+ }
+
+ return 0;
+ }
+
+ __declspec(dllexport) int FindAll(ElementInformationPtr parent, ElementInformation** elements, const char* treeScope, char* errorInfo, const int errorInfoLength, const int count, SearchConditionPtr arg0, ...) {
+ va_list arguments;
+ va_start(arguments, arg0);
+
+ list<SearchConditionPtr> conditions;
+ conditions.push_back(arg0);
+ for(auto index = 1; index < count; index++) {
+ conditions.push_back(va_arg(arguments, SearchConditionPtr));
+ }
+
+ return ManagedFindAll(parent, elements, treeScope, conditions, errorInfo, errorInfoLength);
+ }
+
__declspec(dllexport) ElementInformationPtr Element_FindById(const char* automationId, char* errorInfo, const int errorLength) {
try {
return ElementInformation::From(Element::ById(gcnew String(automationId)));
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
@@ -117,48 +142,48 @@
}
}
__declspec(dllexport) int Element_Children(ElementInformationPtr parentElement, ElementInformation** children, char* errorInfo, const int errorLength) {
try {
- auto elements = Find(parentElement)->Children;
+ auto elements = ElementFrom(parentElement)->Children;
*children = ElementInformation::From(elements);
return elements->Length;
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
return 0;
}
}
__declspec(dllexport) int Element_Descendants(ElementInformationPtr parentElement, ElementInformation** descendants, char* errorInfo, const int errorLength) {
try {
- auto elements = Find(parentElement)->Descendants;
+ auto elements = ElementFrom(parentElement)->Descendants;
*descendants = ElementInformation::From(elements);
return elements->Length;
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
return 0;
}
}
__declspec(dllexport) void Element_ClickClickablePoint(ElementInformationPtr element, char* errorInfo, const int errorLength) {
try {
- Find(element)->ClickClickablePoint();
+ ElementFrom(element)->ClickClickablePoint();
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
}
}
__declspec(dllexport) void Element_ClickCenter(ElementInformationPtr element, char* errorInfo, const int errorLength) {
try {
- Find(element)->ClickCenter();
+ ElementFrom(element)->ClickCenter();
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
}
}
__declspec(dllexport) void Element_Focus(ElementInformationPtr element, char* errorInfo, const int errorLength) {
try {
- Find(element)->SetFocus();
+ ElementFrom(element)->SetFocus();
} catch(Exception^ error) {
StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
}
}
\ No newline at end of file