ext/UiaDll/UiaDll/ElementMethods.cpp in uia-0.1.2.3 vs ext/UiaDll/UiaDll/ElementMethods.cpp in uia-0.1.3

- old
+ new

@@ -1,7 +1,8 @@ #include "Stdafx.h" +#include "ConditionHelper.h" using namespace UIA::Helper; extern "C" { Element^ Find(ElementInformationPtr element) { if( element->nativeWindowHandle > 0 ) { @@ -29,44 +30,46 @@ } catch(Exception^ e) { StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength); } } - __declspec(dllexport) ElementInformationPtr Element_FindById(const char* automationId, char* errorInfo, const int errorLength) { + ElementInformationPtr ManagedFindByConditions(ElementInformationPtr element, const char* treeScope, list<SearchConditionPtr>& conditions, char* errorInfo, const int errorInfoLength) { try { - return ElementInformation::From(Element::ById(gcnew String(automationId))); - } catch(Exception^ error) { - StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength); + auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope)); + return ElementInformation::From(Find(element)->ChildWith(scope, ConditionHelper::ConditionFrom(conditions))); + } catch(Exception^ e) { + StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength); } return NULL; } - __declspec(dllexport) ElementInformationPtr Element_FindChildById(ElementInformationPtr parent, const char* automationId, const char* treeScope, char* errorInfo, const int errorLength) { - try { - auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope)); - return ElementInformation::From(Find(parent)->ChildById(gcnew String(automationId), scope)); - } catch(Exception^ error) { - StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength); + __declspec(dllexport) ElementInformationPtr FindByConditions(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 NULL; + return ManagedFindByConditions(element, treeScope, conditions, errorInfo, errorInfoLength); } - __declspec(dllexport) ElementInformationPtr Element_FindByName(const char* name, char* errorInfo, const int errorLength) { + __declspec(dllexport) ElementInformationPtr Element_FindById(const char* automationId, char* errorInfo, const int errorLength) { try { - return ElementInformation::From(Element::ByName(gcnew String(name))); + return ElementInformation::From(Element::ById(gcnew String(automationId))); } catch(Exception^ error) { StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength); } return NULL; } - __declspec(dllexport) ElementInformationPtr Element_FindChildByName(ElementInformationPtr parent, const char* name, const char* treeScope, char* errorInfo, const int errorLength) { + __declspec(dllexport) ElementInformationPtr Element_FindByName(const char* name, char* errorInfo, const int errorLength) { try { - auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope)); - return ElementInformation::From(Find(parent)->ChildByName(gcnew String(name), scope)); + return ElementInformation::From(Element::ByName(gcnew String(name))); } catch(Exception^ error) { StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength); } return NULL; \ No newline at end of file