@@ -64,6 +64,8 @@ bool EnsureAutomation() {
6464 }
6565 return true ;
6666}
67+
68+ // TODO: get rid of *out parameters
6769bool TryGetFocusedElement (const ComPtr<IUIAutomation>& automation,
6870 ComPtr<IUIAutomationElement>* focused) {
6971 if (!automation || !focused) {
@@ -74,6 +76,7 @@ bool TryGetFocusedElement(const ComPtr<IUIAutomation>& automation,
7476 focused->Get () != nullptr ;
7577}
7678
79+ // TODO: get rid of *out parameters
7780bool TryGetElementFromHandle (const ComPtr<IUIAutomation>& automation,
7881 HWND hwnd,
7982 ComPtr<IUIAutomationElement>* element) {
@@ -85,6 +88,7 @@ bool TryGetElementFromHandle(const ComPtr<IUIAutomation>& automation,
8588 element->Get () != nullptr ;
8689}
8790
91+ // TODO: get rid of *out parameters
8892bool TryGetElementFromPoint (const ComPtr<IUIAutomation>& automation,
8993 POINT pt,
9094 ComPtr<IUIAutomationElement>* element) {
@@ -96,6 +100,7 @@ bool TryGetElementFromPoint(const ComPtr<IUIAutomation>& automation,
96100 element->Get () != nullptr ;
97101}
98102
103+ // TODO: get rid of *out parameters
99104bool TryGetCurrentStringProperty (const ComPtr<IUIAutomationElement>& element,
100105 PROPERTYID property_id,
101106 std::wstring* value) {
@@ -116,6 +121,10 @@ bool TryGetCurrentStringProperty(const ComPtr<IUIAutomationElement>& element,
116121ComPtr<IUIAutomationCondition> MakeClassCondition (
117122 const ComPtr<IUIAutomation>& automation,
118123 std::wstring_view class_name) {
124+ if (!automation || class_name.empty ()) {
125+ return nullptr ;
126+ }
127+
119128 ScopedVariant val;
120129 val.value .vt = VT_BSTR;
121130 val.value .bstrVal = SysAllocStringLen (class_name.data (),
@@ -128,9 +137,7 @@ ComPtr<IUIAutomationCondition> MakeClassCondition(
128137 if (FAILED (automation->CreatePropertyCondition (
129138 UIA_ClassNamePropertyId, val.value ,
130139 condition.ReleaseAndGetAddressOf ()))) {
131- {
132- return nullptr ;
133- }
140+ return nullptr ;
134141 }
135142 return condition;
136143}
@@ -168,6 +175,7 @@ ComPtr<IUIAutomationElement> FindFirstInSubtree(
168175 return hit;
169176}
170177
178+ // TODO: get rid of *out parameters
171179bool FindSiblingByClass (const ComPtr<IUIAutomation>& automation,
172180 const ComPtr<IUIAutomationElement>& element,
173181 std::wstring_view class_name,
0 commit comments