appium-novawindows2-driver 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,512 +4,492 @@ exports.FoundAutomationElement = exports.AutomationElementGroup = exports.Automa
4
4
  const core_1 = require("./core");
5
5
  const common_1 = require("./common");
6
6
  // TODO: Move the methods to a separate file, some of them are too complicated and are not easy to maintain
7
- const FIND_ALL_ANCESTOR = (0, core_1.pwsh$ /* ps1 */) `
8
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
9
- $els = New-Object System.Collections.Generic.List[AutomationElement]
10
-
11
- ${0} | ForEach-Object {
12
- $el = $_
13
- while ($null -ne ($parent = $treeWalker.GetParent($el))) {
14
- $el = $parent
15
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
16
-
17
- if ($null -ne $validEl) {
18
- $els.Add($validEl)
19
- }
20
- }
21
- }
22
-
23
- Write-Output $els
7
+ const FIND_ALL_ANCESTOR = (0, core_1.pwsh$ /* ps1 */) `
8
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
9
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
10
+
11
+ ${0} | ForEach-Object {
12
+ $el = $_
13
+ while ($null -ne ($parent = $treeWalker.GetParent($el))) {
14
+ $el = $parent
15
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
16
+
17
+ if ($null -ne $validEl) {
18
+ $els.Add($validEl)
19
+ }
20
+ }
21
+ }
22
+
23
+ Write-Output $els
24
24
  `;
25
- const FIND_FIRST_ANCESTOR = (0, core_1.pwsh$ /* ps1 */) `
26
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
27
-
28
- ${0} | ForEach-Object {
29
- $el = $_
30
- while ($null -ne ($parent = $treeWalker.GetParent($el))) {
31
- $el = $parent
32
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
33
-
34
- if ($null -ne $validEl) {
35
- Write-Output $el
36
- break
37
- }
38
- }
39
- }
25
+ const FIND_FIRST_ANCESTOR = (0, core_1.pwsh$ /* ps1 */) `
26
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
27
+
28
+ ${0} | ForEach-Object {
29
+ $el = $_
30
+ while ($null -ne ($parent = $treeWalker.GetParent($el))) {
31
+ $el = $parent
32
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
33
+
34
+ if ($null -ne $validEl) {
35
+ Write-Output $el
36
+ break
37
+ }
38
+ }
39
+ }
40
40
  `;
41
- const FIND_ALL_ANCESTOR_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
42
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
43
- $els = New-Object System.Collections.Generic.List[AutomationElement]
44
-
45
- ${0} | ForEach-Object {
46
- $el = $_
47
- while ($null -ne $el) {
48
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
49
-
50
- if ($null -ne $validEl) {
51
- $els.Add($validEl)
52
- }
53
-
54
- $el = $treeWalker.GetParent($el)
55
- }
56
- }
57
-
58
- Write-Output $els
41
+ const FIND_ALL_ANCESTOR_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
42
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
43
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
44
+
45
+ ${0} | ForEach-Object {
46
+ $el = $_
47
+ while ($null -ne $el) {
48
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
49
+
50
+ if ($null -ne $validEl) {
51
+ $els.Add($validEl)
52
+ }
53
+
54
+ $el = $treeWalker.GetParent($el)
55
+ }
56
+ }
57
+
58
+ Write-Output $els
59
59
  `;
60
- const FIND_FIRST_ANCESTOR_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
61
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
62
-
63
- ${0} | ForEach-Object {
64
- $el = $_
65
- while ($null -ne $el) {
66
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
67
-
68
- if ($null -ne $validEl) {
69
- Write-Output $el
70
- break
71
- }
72
-
73
- $el = $treeWalker.GetParent($el)
74
- }
75
- }
60
+ const FIND_FIRST_ANCESTOR_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
61
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
62
+
63
+ ${0} | ForEach-Object {
64
+ $el = $_
65
+ while ($null -ne $el) {
66
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
67
+
68
+ if ($null -ne $validEl) {
69
+ Write-Output $el
70
+ break
71
+ }
72
+
73
+ $el = $treeWalker.GetParent($el)
74
+ }
75
+ }
76
76
  `;
77
- const FIND_PARENT = (0, core_1.pwsh$ /* ps1 */) `
78
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
79
-
80
- ${0} | ForEach-Object {
81
- $el = $_
82
- $el = $treeWalker.GetParent($el).FindFirst([TreeScope]::Element, ${1})
83
- Write-Output $el
84
- }
77
+ const FIND_PARENT = (0, core_1.pwsh$ /* ps1 */) `
78
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
79
+
80
+ ${0} | ForEach-Object {
81
+ $el = $_
82
+ $el = $treeWalker.GetParent($el).FindFirst([TreeScope]::Element, ${1})
83
+ Write-Output $el
84
+ }
85
85
  `;
86
- const FIND_FOLLOWING = (0, core_1.pwsh$ /* ps1 */) `
87
- $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
88
- $els = New-Object System.Collections.Generic.List[AutomationElement]
89
-
90
- ${0} | ForEach-Object {
91
- $el = $_
92
- while ($null -ne $el) {
93
- if ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
94
- $el = $nextSibling
95
-
96
- Write-Output $el
97
- break
98
- }
99
-
100
- $el = $treeWalker.GetParent($el)
101
- }
102
- }
86
+ const FIND_FOLLOWING = (0, core_1.pwsh$ /* ps1 */) `
87
+ $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
88
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
89
+
90
+ ${0} | ForEach-Object {
91
+ $el = $_
92
+ while ($null -ne $el) {
93
+ if ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
94
+ $el = $nextSibling
95
+
96
+ Write-Output $el
97
+ break
98
+ }
99
+
100
+ $el = $treeWalker.GetParent($el)
101
+ }
102
+ }
103
103
  `;
104
- const FIND_ALL_FOLLOWING = (0, core_1.pwsh$ /* ps1 */) `
105
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
106
- $els = New-Object System.Collections.Generic.List[AutomationElement]
107
- $childWalker = [TreeWalker]::new(${1})
108
-
109
- ${0} | ForEach-Object {
110
- $el = $_
111
- while ($null -ne $el) {
112
- if ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
113
- $el = $nextSibling
114
- $els.Add($el)
115
-
116
- # Recursive sibling find-all
117
- $c = $childWalker.GetFirstChild($el)
118
- while ($null -ne $c) {
119
- $els.Add($c)
120
- $c = $childWalker.GetNextSibling($c)
121
- }
122
- }
123
-
124
- $el = $treeWalker.GetParent($el)
125
- }
126
- }
127
-
128
- Write-Output $els
104
+ const FIND_ALL_FOLLOWING = (0, core_1.pwsh$ /* ps1 */) `
105
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
106
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
107
+
108
+ ${0} | ForEach-Object {
109
+ $el = $_
110
+ while ($null -ne $el) {
111
+ if ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
112
+ $el = $nextSibling
113
+ $els.Add($el)
114
+ $els.AddRange($el.FindAll([TreeScope]::Children, ${1}))
115
+ }
116
+
117
+ $el = $treeWalker.GetParent($el)
118
+ }
119
+ }
120
+
121
+ Write-Output $els
129
122
  `;
130
- const FIND_FOLLOWING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
131
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
132
-
133
- ${0} | ForEach-Object {
134
- $el = $_
135
- while ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
136
- $el = $nextSibling
137
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
138
-
139
- if ($null -ne $validEl) {
140
- Write-Output $el
141
- break
142
- }
143
- }
144
- }
123
+ const FIND_FOLLOWING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
124
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
125
+
126
+ ${0} | ForEach-Object {
127
+ $el = $_
128
+ while ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
129
+ $el = $nextSibling
130
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
131
+
132
+ if ($null -ne $validEl) {
133
+ Write-Output $el
134
+ break
135
+ }
136
+ }
137
+ }
145
138
  `;
146
- const FIND_ALL_FOLLOWING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
147
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
148
- $els = New-Object System.Collections.Generic.List[AutomationElement]
149
-
150
- ${0} | ForEach-Object {
151
- $el = $_
152
- while ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
153
- $el = $nextSibling
154
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
155
-
156
- if ($null -ne $validEl) {
157
- $els.Add($validEl)
158
- }
159
- }
160
- }
161
-
162
- Write-Output $els
139
+ const FIND_ALL_FOLLOWING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
140
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
141
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
142
+
143
+ ${0} | ForEach-Object {
144
+ $el = $_
145
+ while ($null -ne ($nextSibling = $treeWalker.GetNextSibling($el))) {
146
+ $el = $nextSibling
147
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
148
+
149
+ if ($null -ne $validEl) {
150
+ $els.Add($validEl)
151
+ }
152
+ }
153
+ }
154
+
155
+ Write-Output $els
163
156
  `;
164
- const FIND_PRECEDING = (0, core_1.pwsh$ /* ps1 */) `
165
- $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
166
-
167
- ${0} | ForEach-Object {
168
- $el = $_
169
- while ($null -ne $el) {
170
- if ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
171
- $el = $previousSibling
172
-
173
- Write-Output $el
174
- break
175
- }
176
-
177
- $el = $treeWalker.GetParent($el)
178
- }
179
- }
157
+ const FIND_PRECEDING = (0, core_1.pwsh$ /* ps1 */) `
158
+ $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
159
+
160
+ ${0} | ForEach-Object {
161
+ $el = $_
162
+ while ($null -ne $el) {
163
+ if ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
164
+ $el = $previousSibling
165
+
166
+ Write-Output $el
167
+ break
168
+ }
169
+
170
+ $el = $treeWalker.GetParent($el)
171
+ }
172
+ }
180
173
  `;
181
- const FIND_ALL_PRECEDING = (0, core_1.pwsh$ /* ps1 */) `
182
- $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
183
- $els = New-Object System.Collections.Generic.List[AutomationElement]
184
- $childWalker = [TreeWalker]::new(${1})
185
-
186
- ${0} | ForEach-Object {
187
- $el = $_
188
- while ($null -ne $el) {
189
- if ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
190
- $el = $previousSibling
191
- $els.Add($el)
192
-
193
- # Sibling children find-all
194
- $c = $childWalker.GetFirstChild($el)
195
- while ($null -ne $c) {
196
- $els.Add($c)
197
- $c = $childWalker.GetNextSibling($c)
198
- }
199
- }
200
-
201
- $el = $treeWalker.GetParent($el)
202
- }
203
- }
204
-
205
- Write-Output $els
174
+ const FIND_ALL_PRECEDING = (0, core_1.pwsh$ /* ps1 */) `
175
+ $treeWalker = [TreeWalker]::new([AndCondition]::new($cacheRequest.TreeFilter, ${1}))
176
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
177
+
178
+ ${0} | ForEach-Object {
179
+ $el = $_
180
+ while ($null -ne $el) {
181
+ if ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
182
+ $el = $previousSibling
183
+ $els.Add($el)
184
+ $els.AddRange($el.FindAll([TreeScope]::Children, ${1}))
185
+ }
186
+
187
+ $el = $treeWalker.GetParent($el)
188
+ }
189
+ }
190
+
191
+ Write-Output $els
206
192
  `;
207
- const FIND_PRECEDING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
208
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
209
-
210
- ${0} | ForEach-Object {
211
- $el = $_
212
- while ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
213
- $el = $previousSibling
214
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
215
-
216
- if ($null -ne $validEl) {
217
- Write-Output $el
218
- break
219
- }
220
- }
221
- }
193
+ const FIND_PRECEDING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
194
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
195
+
196
+ ${0} | ForEach-Object {
197
+ $el = $_
198
+ while ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
199
+ $el = $previousSibling
200
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
201
+
202
+ if ($null -ne $validEl) {
203
+ Write-Output $el
204
+ break
205
+ }
206
+ }
207
+ }
222
208
  `;
223
- const FIND_ALL_PRECEDING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
224
- $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
225
- $els = New-Object System.Collections.Generic.List[AutomationElement]
226
-
227
- ${0} | ForEach-Object {
228
- $el = $_
229
- while ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
230
- $el = $previousSibling
231
- $validEl = $el.FindFirst([TreeScope]::Element, ${1})
232
-
233
- if ($null -ne $validEl) {
234
- $els.Add($validEl)
235
- }
236
- }
237
- }
238
-
239
- Write-Output $els
209
+ const FIND_ALL_PRECEDING_SIBLING = (0, core_1.pwsh$ /* ps1 */) `
210
+ $treeWalker = [TreeWalker]::new($cacheRequest.TreeFilter)
211
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
212
+
213
+ ${0} | ForEach-Object {
214
+ $el = $_
215
+ while ($null -ne ($previousSibling = $treeWalker.GetPreviousSibling($el))) {
216
+ $el = $previousSibling
217
+ $validEl = $el.FindFirst([TreeScope]::Element, ${1})
218
+
219
+ if ($null -ne $validEl) {
220
+ $els.Add($validEl)
221
+ }
222
+ }
223
+ }
224
+
225
+ Write-Output $els
240
226
  `;
241
- const FIND_CHILDREN_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
242
- $els = New-Object System.Collections.Generic.List[AutomationElement]
243
-
244
- ${0} | ForEach-Object {
245
- $el = $_
246
- $validEl = $el.FindFirst([TreeScope]::Element -bor [TreeScope]::Children, ${1});
247
-
248
- if ($null -ne $validEl) {
249
- $els.Add($validEl)
250
- }
251
- }
252
-
253
- Write-Output $els
227
+ const FIND_CHILDREN_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
228
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
229
+
230
+ ${0} | ForEach-Object {
231
+ $el = $_
232
+ $validEl = $el.FindFirst([TreeScope]::Element -bor [TreeScope]::Children, ${1});
233
+
234
+ if ($null -ne $validEl) {
235
+ $els.Add($validEl)
236
+ }
237
+ }
238
+
239
+ Write-Output $els
254
240
  `;
255
- const FIND_ALL_CHILDREN_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
256
- $els = New-Object System.Collections.Generic.List[AutomationElement]
257
- $walker = [TreeWalker]::new(${1})
258
-
259
- ${0} | ForEach-Object {
260
- $el = $_
261
- if ($null -ne $el.FindFirst([TreeScope]::Element, ${1})) {
262
- $els.Add($el)
263
- }
264
- $child = $walker.GetFirstChild($el)
265
- while ($null -ne $child) {
266
- $els.Add($child)
267
- $child = $walker.GetNextSibling($child)
268
- }
269
- }
270
-
271
- Write-Output $els
241
+ const FIND_ALL_CHILDREN_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
242
+ $els = New-Object System.Collections.Generic.List[AutomationElement]
243
+
244
+ ${0} | ForEach-Object {
245
+ $el = $_
246
+ $validEl = $el.FindAll([TreeScope]::Element -bor [TreeScope]::Children, ${1});
247
+
248
+ if ($null -ne $validEl) {
249
+ $els.Add($validEl)
250
+ }
251
+ }
252
+
253
+ Write-Output $els
272
254
  `;
273
255
  const FIND_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `Find-ChildrenRecursively -element (${0}) -condition (${1})`;
274
256
  const FIND_ALL_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `Find-AllChildrenRecursively -element (${0}) -condition (${1})`;
275
257
  const FIND_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `Find-ChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true`;
276
258
  const FIND_ALL_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `Find-AllChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true`;
277
259
  const FIND_FIRST = (0, core_1.pwsh$ /* ps1 */) `${0}.FindFirst([TreeScope]::${1}, ${2})`;
278
- const FIND_ALL = (0, core_1.pwsh$ /* ps1 */) `
279
- if ("${1}" -eq "Children") {
280
- $walker = [TreeWalker]::new(${2})
281
- $els = New-Object System.Collections.Generic.List[AutomationElement]
282
- $child = $walker.GetFirstChild(${0})
283
- while ($null -ne $child) {
284
- $els.Add($child)
285
- $child = $walker.GetNextSibling($child)
286
- }
287
- $els
288
- } else {
289
- ${0}.FindAll([TreeScope]::${1}, ${2})
290
- }
291
- `;
260
+ const FIND_ALL = (0, core_1.pwsh$ /* ps1 */) `${0}.FindAll([TreeScope]::${1}, ${2})`;
292
261
  const AUTOMATION_ROOT = /* ps1 */ `$rootElement`;
293
262
  const FOCUSED_ELEMENT = /* ps1 */ `[AutomationElement]::FocusedElement`;
294
263
  const ROOT_ELEMENT = /* ps1 */ `[AutomationElement]::RootElement`;
295
- const SAVE_TO_ELEMENT_TABLE_AND_RETURN_ID = (0, core_1.pwsh$ /* ps1 */) `
296
- ${0} | Where-Object { $null -ne $_ } | ForEach-Object {
297
- $runtimeId = $_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.';
298
-
299
- if (-not $elementTable.ContainsKey($runtimeId)) {
300
- $elementTable.Add($runtimeId, $_)
301
- };
302
-
303
- $runtimeId
304
- }
264
+ const SAVE_TO_ELEMENT_TABLE_AND_RETURN_ID = (0, core_1.pwsh$ /* ps1 */) `
265
+ ${0} | Where-Object { $null -ne $_ } | ForEach-Object {
266
+ $runtimeId = $_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.';
267
+
268
+ if (-not $elementTable.ContainsKey($runtimeId)) {
269
+ $elementTable.Add($runtimeId, $_)
270
+ };
271
+
272
+ $runtimeId
273
+ }
305
274
  `;
306
275
  const ELEMENT_TABLE_GET = (0, core_1.pwsh$ /* ps1 */) `$elementTable['${0}']`;
307
276
  // TODO: maybe encode the result first? Some properties may be on multiple lines, it may cause a problem when returning multiple element results at once
308
- const GET_CACHED_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCachedPropertyValue([AutomationElement]::${1}Property) } catch { ${0}.GetCurrentPropertyValue([AutomationElement]::${1}Property) } }`;
309
- const GET_CURRENT_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
310
- if ($null -ne ${0}) {
311
- try {
312
- $target = "${1}"
313
-
314
- # 1. Handle dotted Pattern.Property format (e.g. Window.CanMaximize or LegacyIAccessible.Name)
315
- if ($target.Contains(".")) {
316
- $parts = $target.Split(".")
317
- if ($parts.Length -ge 2) {
318
- $pKey = $parts[0]
319
- $propName = $parts[1]
320
-
321
- # Sweep supported properties for a match on the programmatic name (pattern + property)
322
- foreach ($prop in ${0}.GetSupportedProperties()) {
323
- # ProgrammaticName is usually something like "WindowPatternIdentifiers.CanMaximizeProperty"
324
- if ($prop.ProgrammaticName -like "*$pKey*$propName*") {
325
- $val = ${0}.GetCurrentPropertyValue($prop)
326
- if ($null -ne $val) { return $val.ToString() }
327
- }
328
- }
329
-
330
- # Custom Aliases / MSAA Fallback for dotted names (LegacyIAccessible.Name -> Name)
331
- if ($pKey -eq "LegacyIAccessible") {
332
- if ($propName -eq "Name") { return ${0}.Current.Name }
333
- if ($propName -eq "Description") { return ${0}.Current.HelpText }
334
- if ($propName -eq "Role") { return ${0}.Current.LocalizedControlType }
335
- if ($propName -eq "State") { return "" }
336
- if ($propName -eq "Value") { return "" }
337
- }
338
- }
339
- }
340
-
341
- # 2. Try standard AutomationElement property (e.g. NameProperty)
342
- try {
343
- $p = [System.Windows.Automation.AutomationElement]::($target + "Property")
344
- if ($null -ne $p) {
345
- $val = ${0}.GetCurrentPropertyValue($p)
346
- if ($null -ne $val) { return $val.ToString() }
347
- }
348
- } catch {}
349
-
350
- # 3. Fallback search through all supported properties for short names (e.g. "CanMaximize")
351
- foreach ($prop in ${0}.GetSupportedProperties()) {
352
- if ($prop.ProgrammaticName.EndsWith(".$($target)Property") -or $prop.ProgrammaticName.Contains(".$($target)")) {
353
- $val = ${0}.GetCurrentPropertyValue($prop)
354
- if ($null -ne $val) { return $val.ToString() }
355
- }
356
- }
357
-
358
- # 4. Try pattern-based lookup for short names using common identifiers
359
- $commonPatterns = @("Window", "Transform", "ExpandCollapse", "Toggle", "Value", "RangeValue", "LegacyIAccessible")
360
- foreach ($pKey in $commonPatterns) {
361
- try {
362
- $pTypeName = "System.Windows.Automation.$($pKey)Pattern"
363
- $pProp = Invoke-Expression "[$pTypeName]::$($target)Property"
364
- if ($null -ne $pProp) {
365
- $val = ${0}.GetCurrentPropertyValue($pProp)
366
- if ($null -ne $val) { return $val.ToString() }
367
- }
368
- } catch {}
369
- }
370
-
371
- # 5. UIA 3.0 / Driver-specific aliases (Safe Defaults)
372
- if ($target -eq "IsDialog") { return "False" }
373
- if ($target -eq "ProviderDescription") { return "" }
374
- if ($target -eq "LegacyName") { return ${0}.Current.Name }
375
-
376
- } catch { return $null }
377
- }
277
+ const GET_CACHED_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
278
+ if ($null -ne ${0}) {
279
+ try {
280
+ ${0}.GetCachedPropertyValue([AutomationElement]::${1}Property)
281
+ } catch {
282
+ ${0}.GetCurrentPropertyValue([AutomationElement]::${1}Property)
283
+ }
284
+ }
378
285
  `;
379
- const GET_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
380
- try {
381
- $prop = [AutomationElement]::${1}Property
382
- if ($null -ne $prop) {
383
- try {
384
- ${0}.GetCachedPropertyValue($prop)
385
- } catch {
386
- ${0}.GetCurrentPropertyValue($prop)
387
- }
388
- } else { $null }
389
- } catch {
390
- $null
391
- }
286
+ const GET_CURRENT_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
287
+ if ($null -ne ${0}) {
288
+ try {
289
+ $target = "${1}"
290
+
291
+ # 1. Handle dotted Pattern.Property format (e.g. Window.CanMaximize or LegacyIAccessible.Name)
292
+ if ($target.Contains(".")) {
293
+ $parts = $target.Split(".")
294
+ if ($parts.Length -ge 2) {
295
+ $pKey = $parts[0]
296
+ $propName = $parts[1]
297
+
298
+ # Sweep supported properties for a match on the programmatic name (pattern + property)
299
+ foreach ($prop in ${0}.GetSupportedProperties()) {
300
+ # ProgrammaticName is usually something like "WindowPatternIdentifiers.CanMaximizeProperty"
301
+ if ($prop.ProgrammaticName -like "*$pKey*$propName*") {
302
+ $val = ${0}.GetCurrentPropertyValue($prop)
303
+ if ($null -ne $val) { return $val.ToString() }
304
+ }
305
+ }
306
+
307
+ # Custom Aliases / MSAA Fallback for dotted names (LegacyIAccessible.Name -> Name)
308
+ if ($pKey -eq "LegacyIAccessible") {
309
+ if ($propName -eq "Name") { return ${0}.Current.Name }
310
+ if ($propName -eq "Description") { return ${0}.Current.HelpText }
311
+ if ($propName -eq "Role") { return ${0}.Current.LocalizedControlType }
312
+ if ($propName -eq "State") { return "" }
313
+ if ($propName -eq "Value") { return "" }
314
+ }
315
+ }
316
+ }
317
+
318
+ # 2. Try standard AutomationElement property (e.g. NameProperty)
319
+ try {
320
+ $p = [System.Windows.Automation.AutomationElement]::($target + "Property")
321
+ if ($null -ne $p) {
322
+ $val = ${0}.GetCurrentPropertyValue($p)
323
+ if ($null -ne $val) { return $val.ToString() }
324
+ }
325
+ } catch {}
326
+
327
+ # 3. Fallback search through all supported properties for short names (e.g. "CanMaximize")
328
+ foreach ($prop in ${0}.GetSupportedProperties()) {
329
+ if ($prop.ProgrammaticName.EndsWith(".$($target)Property") -or $prop.ProgrammaticName.Contains(".$($target)")) {
330
+ $val = ${0}.GetCurrentPropertyValue($prop)
331
+ if ($null -ne $val) { return $val.ToString() }
332
+ }
333
+ }
334
+
335
+ # 4. Try pattern-based lookup for short names using common identifiers
336
+ $commonPatterns = @("Window", "Transform", "ExpandCollapse", "Toggle", "Value", "RangeValue", "LegacyIAccessible")
337
+ foreach ($pKey in $commonPatterns) {
338
+ try {
339
+ $pTypeName = "System.Windows.Automation.$($pKey)Pattern"
340
+ $pProp = Invoke-Expression "[$pTypeName]::$($target)Property"
341
+ if ($null -ne $pProp) {
342
+ $val = ${0}.GetCurrentPropertyValue($pProp)
343
+ if ($null -ne $val) { return $val.ToString() }
344
+ }
345
+ } catch {}
346
+ }
347
+
348
+ # 5. UIA 3.0 / Driver-specific aliases (Safe Defaults)
349
+ if ($target -eq "IsDialog") { return "False" }
350
+ if ($target -eq "ProviderDescription") { return "" }
351
+ if ($target -eq "LegacyName") { return ${0}.Current.Name }
352
+
353
+ } catch { return $null }
354
+ }
392
355
  `;
393
- const GET_ELEMENT_RUNTIME_ID = (0, core_1.pwsh$ /* ps1 */) `
394
- ${0} | ForEach-Object {
395
- $_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.'
396
- }
356
+ const GET_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
357
+ try {
358
+ $prop = [AutomationElement]::${1}Property
359
+ if ($null -ne $prop) {
360
+ try {
361
+ ${0}.GetCachedPropertyValue($prop)
362
+ } catch {
363
+ ${0}.GetCurrentPropertyValue($prop)
364
+ }
365
+ } else { $null }
366
+ } catch {
367
+ $null
368
+ }
397
369
  `;
398
- const GET_ELEMENT_RECT = (0, core_1.pwsh$ /* ps1 */) `
399
- if ($null -ne ${0}) {
400
- try { $rect = ${0}.Cached.BoundingRectangle } catch { $rect = ${0}.Current.BoundingRectangle }
401
- $rect | Select-Object X, Y, Width, Height | ForEach-Object { $_ | ConvertTo-Json -Compress } | ForEach-Object { if ($null -ne $_) { $_.ToLower() } }
402
- }
370
+ const GET_ELEMENT_RUNTIME_ID = (0, core_1.pwsh$ /* ps1 */) `
371
+ ${0} | ForEach-Object {
372
+ $_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.'
373
+ }
403
374
  `;
404
- const GET_ELEMENT_LEGACY_VALUE = (0, core_1.pwsh$ /* ps1 */) `
405
- try {
406
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Value
407
- } catch {
408
- try {
409
- $hwnd = ${0}.Current.NativeWindowHandle
410
- if ($hwnd -gt 0) {
411
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
412
- } else { $null }
413
- } catch { $null }
414
- }
375
+ const GET_ELEMENT_RECT = (0, core_1.pwsh$ /* ps1 */) `
376
+ if ($null -ne ${0}) {
377
+ try { $rect = ${0}.Cached.BoundingRectangle } catch { $rect = ${0}.Current.BoundingRectangle }
378
+ $rect |
379
+ Select-Object X, Y, Width, Height |
380
+ ForEach-Object { $_ | ConvertTo-Json -Compress } |
381
+ ForEach-Object { if ($null -ne $_) { $_.ToLower() } }
382
+ }
415
383
  `;
416
- const GET_ELEMENT_LEGACY_NAME = (0, core_1.pwsh$ /* ps1 */) `
417
- if ($null -ne ${0}) {
418
- try {
419
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Name
420
- } catch {
421
- try {
422
- $hwnd = ${0}.Current.NativeWindowHandle
423
- if ($hwnd -gt 0) {
424
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accName")
425
- } else { $null }
426
- } catch { $null }
427
- }
428
- }
384
+ const GET_ELEMENT_LEGACY_VALUE = (0, core_1.pwsh$ /* ps1 */) `
385
+ try {
386
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Value
387
+ } catch {
388
+ try {
389
+ $hwnd = ${0}.Current.NativeWindowHandle
390
+ if ($hwnd -gt 0) {
391
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
392
+ } else { $null }
393
+ } catch { $null }
394
+ }
429
395
  `;
430
- const GET_ELEMENT_LEGACY_DESCRIPTION = (0, core_1.pwsh$ /* ps1 */) `
431
- if ($null -ne ${0}) {
432
- try {
433
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Description
434
- } catch {
435
- try {
436
- $hwnd = ${0}.Current.NativeWindowHandle
437
- if ($hwnd -gt 0) {
438
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDescription")
439
- } else { $null }
440
- } catch { $null }
441
- }
442
- }
396
+ const GET_ELEMENT_LEGACY_NAME = (0, core_1.pwsh$ /* ps1 */) `
397
+ if ($null -ne ${0}) {
398
+ try {
399
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Name
400
+ } catch {
401
+ try {
402
+ $hwnd = ${0}.Current.NativeWindowHandle
403
+ if ($hwnd -gt 0) {
404
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accName")
405
+ } else { $null }
406
+ } catch { $null }
407
+ }
408
+ }
443
409
  `;
444
- const GET_ELEMENT_LEGACY_ROLE = (0, core_1.pwsh$ /* ps1 */) `
445
- if ($null -ne ${0}) {
446
- try {
447
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Role
448
- } catch {
449
- try {
450
- $hwnd = ${0}.Current.NativeWindowHandle
451
- if ($hwnd -gt 0) {
452
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accRole")
453
- } else { $null }
454
- } catch { $null }
455
- }
456
- }
410
+ const GET_ELEMENT_LEGACY_DESCRIPTION = (0, core_1.pwsh$ /* ps1 */) `
411
+ if ($null -ne ${0}) {
412
+ try {
413
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Description
414
+ } catch {
415
+ try {
416
+ $hwnd = ${0}.Current.NativeWindowHandle
417
+ if ($hwnd -gt 0) {
418
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDescription")
419
+ } else { $null }
420
+ } catch { $null }
421
+ }
422
+ }
457
423
  `;
458
- const GET_ELEMENT_LEGACY_STATE = (0, core_1.pwsh$ /* ps1 */) `
459
- if ($null -ne ${0}) {
460
- try {
461
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.State
462
- } catch {
463
- try {
464
- $hwnd = ${0}.Current.NativeWindowHandle
465
- if ($hwnd -gt 0) {
466
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState")
467
- } else { $null }
468
- } catch { $null }
469
- }
470
- }
424
+ const GET_ELEMENT_LEGACY_ROLE = (0, core_1.pwsh$ /* ps1 */) `
425
+ if ($null -ne ${0}) {
426
+ try {
427
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Role
428
+ } catch {
429
+ try {
430
+ $hwnd = ${0}.Current.NativeWindowHandle
431
+ if ($hwnd -gt 0) {
432
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accRole")
433
+ } else { $null }
434
+ } catch { $null }
435
+ }
436
+ }
471
437
  `;
472
- const GET_ELEMENT_LEGACY_HELP = (0, core_1.pwsh$ /* ps1 */) `
473
- if ($null -ne ${0}) {
474
- try {
475
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Help
476
- } catch {
477
- try {
478
- $hwnd = ${0}.Current.NativeWindowHandle
479
- if ($hwnd -gt 0) {
480
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accHelp")
481
- } else { $null }
482
- } catch { $null }
483
- }
484
- }
438
+ const GET_ELEMENT_LEGACY_STATE = (0, core_1.pwsh$ /* ps1 */) `
439
+ if ($null -ne ${0}) {
440
+ try {
441
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.State
442
+ } catch {
443
+ try {
444
+ $hwnd = ${0}.Current.NativeWindowHandle
445
+ if ($hwnd -gt 0) {
446
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState")
447
+ } else { $null }
448
+ } catch { $null }
449
+ }
450
+ }
485
451
  `;
486
- const GET_ELEMENT_LEGACY_KEYBOARD_SHORTCUT = (0, core_1.pwsh$ /* ps1 */) `
487
- if ($null -ne ${0}) {
488
- try {
489
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.KeyboardShortcut
490
- } catch {
491
- try {
492
- $hwnd = ${0}.Current.NativeWindowHandle
493
- if ($hwnd -gt 0) {
494
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accKeyboardShortcut")
495
- } else { $null }
496
- } catch { $null }
497
- }
498
- }
452
+ const GET_ELEMENT_LEGACY_HELP = (0, core_1.pwsh$ /* ps1 */) `
453
+ if ($null -ne ${0}) {
454
+ try {
455
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Help
456
+ } catch {
457
+ try {
458
+ $hwnd = ${0}.Current.NativeWindowHandle
459
+ if ($hwnd -gt 0) {
460
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accHelp")
461
+ } else { $null }
462
+ } catch { $null }
463
+ }
464
+ }
499
465
  `;
500
- const GET_ELEMENT_LEGACY_DEFAULT_ACTION = (0, core_1.pwsh$ /* ps1 */) `
501
- if ($null -ne ${0}) {
502
- try {
503
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.DefaultAction
504
- } catch {
505
- try {
506
- $hwnd = ${0}.Current.NativeWindowHandle
507
- if ($hwnd -gt 0) {
508
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDefaultAction")
509
- } else { $null }
510
- } catch { $null }
511
- }
512
- }
466
+ const GET_ELEMENT_LEGACY_KEYBOARD_SHORTCUT = (0, core_1.pwsh$ /* ps1 */) `
467
+ if ($null -ne ${0}) {
468
+ try {
469
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.KeyboardShortcut
470
+ } catch {
471
+ try {
472
+ $hwnd = ${0}.Current.NativeWindowHandle
473
+ if ($hwnd -gt 0) {
474
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accKeyboardShortcut")
475
+ } else { $null }
476
+ } catch { $null }
477
+ }
478
+ }
479
+ `;
480
+ const GET_ELEMENT_LEGACY_DEFAULT_ACTION = (0, core_1.pwsh$ /* ps1 */) `
481
+ if ($null -ne ${0}) {
482
+ try {
483
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.DefaultAction
484
+ } catch {
485
+ try {
486
+ $hwnd = ${0}.Current.NativeWindowHandle
487
+ if ($hwnd -gt 0) {
488
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDefaultAction")
489
+ } else { $null }
490
+ } catch { $null }
491
+ }
492
+ }
513
493
  `;
514
494
  const GET_ELEMENT_WINDOW_CAN_MAXIMIZE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMaximize } catch { $null } }`;
515
495
  const GET_ELEMENT_WINDOW_CAN_MINIMIZE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMinimize } catch { $null } }`;
@@ -520,266 +500,266 @@ const GET_ELEMENT_WINDOW_VISUAL_STATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -
520
500
  const GET_ELEMENT_TRANSFORM_CAN_MOVE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanMove } catch { $null } }`;
521
501
  const GET_ELEMENT_TRANSFORM_CAN_RESIZE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanResize } catch { $null } }`;
522
502
  const GET_ELEMENT_TRANSFORM_CAN_ROTATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanRotate } catch { $null } }`;
523
- const GET_ELEMENT_LEGACY_CHILD_ID = (0, core_1.pwsh$ /* ps1 */) `
524
- if ($null -ne ${0}) {
525
- try {
526
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.ChildId
527
- } catch {
528
- # For HWND based elements, ChildId is usually 0
529
- try {
530
- $hwnd = ${0}.Current.NativeWindowHandle
531
- if ($hwnd -gt 0) {
532
- 0
533
- } else { $null }
534
- } catch { $null }
535
- }
536
- }
503
+ const GET_ELEMENT_LEGACY_CHILD_ID = (0, core_1.pwsh$ /* ps1 */) `
504
+ if ($null -ne ${0}) {
505
+ try {
506
+ ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.ChildId
507
+ } catch {
508
+ # For HWND based elements, ChildId is usually 0
509
+ try {
510
+ $hwnd = ${0}.Current.NativeWindowHandle
511
+ if ($hwnd -gt 0) {
512
+ 0
513
+ } else { $null }
514
+ } catch { $null }
515
+ }
516
+ }
537
517
  `;
538
- const IS_LEGACY_PATTERN_AVAILABLE = (0, core_1.pwsh$ /* ps1 */) `
539
- if ($null -ne ${0}) {
540
- try {
541
- if ($null -ne ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern)) {
542
- $true
543
- } else {
544
- # Only check HWND if managed pattern retrieval explicitly failed/returned null, but we are inside try block
545
- # Actually if GetCurrentPattern throws, we go to catch.
546
- # If it returns null (not supported), we go to else.
547
- $hwnd = ${0}.Current.NativeWindowHandle
548
- $hwnd -gt 0
549
- }
550
- } catch {
551
- # Fallback for TypeNotFound or other UIA errors
552
- try {
553
- $hwnd = ${0}.Current.NativeWindowHandle
554
- $hwnd -gt 0
555
- } catch { $false }
556
- }
557
- } else {
558
- $false
559
- }
518
+ const IS_LEGACY_PATTERN_AVAILABLE = (0, core_1.pwsh$ /* ps1 */) `
519
+ if ($null -ne ${0}) {
520
+ try {
521
+ if ($null -ne ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern)) {
522
+ $true
523
+ } else {
524
+ # Only check HWND if managed pattern retrieval explicitly failed/returned null, but we are inside try block
525
+ # Actually if GetCurrentPattern throws, we go to catch.
526
+ # If it returns null (not supported), we go to else.
527
+ $hwnd = ${0}.Current.NativeWindowHandle
528
+ $hwnd -gt 0
529
+ }
530
+ } catch {
531
+ # Fallback for TypeNotFound or other UIA errors
532
+ try {
533
+ $hwnd = ${0}.Current.NativeWindowHandle
534
+ $hwnd -gt 0
535
+ } catch { $false }
536
+ }
537
+ } else {
538
+ $false
539
+ }
560
540
  `;
561
- const GET_ELEMENT_TAG_NAME = (0, core_1.pwsh$ /* ps1 */) `
562
- if ($null -ne ${0}) {
563
- try { $ct = ${0}.Cached.ControlType } catch { $ct = ${0}.Current.ControlType }
564
- $ct.ProgrammaticName |
565
- ForEach-Object {
566
- $type = $_.Split('.')[-1]
567
- if ($type -eq 'DataGrid') { 'List' }
568
- elseif ($type -eq 'DataItem') { 'ListItem' }
569
- else { $type }
570
- }
571
- }
541
+ const GET_ELEMENT_TAG_NAME = (0, core_1.pwsh$ /* ps1 */) `
542
+ if ($null -ne ${0}) {
543
+ try { $ct = ${0}.Cached.ControlType } catch { $ct = ${0}.Current.ControlType }
544
+ $ct.ProgrammaticName |
545
+ ForEach-Object {
546
+ $type = $_.Split('.')[-1]
547
+ if ($type -eq 'DataGrid') { 'List' }
548
+ elseif ($type -eq 'DataItem') { 'ListItem' }
549
+ else { $type }
550
+ }
551
+ }
572
552
  `;
573
553
  // ... (rest of file)
574
554
  // Inside AutomationElement class (implicit connection via line numbers, I will target the class method efficiently)
575
555
  // Actually I need to insert the constant before buildGetPropertyCommand or at the top with others.
576
556
  // The replace tool works on line ranges. I will convert this to 2 separate edits or use multi_replace.
577
557
  // Let's use multi_replace for cleaner insertion.
578
- const GET_ALL_ELEMENT_PROPERTIES = (0, core_1.pwsh$ /* ps1 */) `
579
- if ($null -ne ${0}) {
580
- $result = @{}
581
-
582
- # 1. Standard Properties from AutomationElement
583
- $standardProps = @(
584
- "Name", "AutomationId", "ClassName", "ControlType", "LocalizedControlType",
585
- "BoundingRectangle", "IsEnabled", "IsOffscreen", "IsKeyboardFocusable",
586
- "HasKeyboardFocus", "AccessKey", "ProcessId", "RuntimeId", "FrameworkId",
587
- "NativeWindowHandle", "IsContentElement", "IsControlElement", "IsPassword",
588
- "HelpText", "ItemStatus", "ItemType", "AcceleratorKey"
589
- )
590
-
591
- foreach ($pName in $standardProps) {
592
- try {
593
- $prop = [AutomationElement]::($pName + "Property")
594
- $val = ${0}.GetCurrentPropertyValue($prop)
595
- if ($null -ne $val) {
596
- if ($pName -eq "RuntimeId") { $result[$pName] = $val -join "." }
597
- else { $result[$pName] = $val.ToString() }
598
- }
599
- } catch {}
600
- }
601
-
602
- # UIA 3.0+ Compatibility (Safe Defaults for UIA 2.0)
603
- $result["IsDialog"] = "False"
604
- $result["ProviderDescription"] = ""
605
-
606
- # 2. Pattern Availability check
607
- $patterns = @(
608
- "Annotation", "Dock", "Drag", "DropTarget", "ExpandCollapse", "GridItem",
609
- "Grid", "Invoke", "ItemContainer", "LegacyIAccessible", "MultipleView",
610
- "ObjectModel", "RangeValue", "ScrollItem", "Scroll", "SelectionItem",
611
- "Selection", "SpreadsheetItem", "Spreadsheet", "Styles", "SynchronizedInput",
612
- "TableItem", "Table", "TextChild", "TextEdit", "Text", "Toggle", "Transform",
613
- "Value", "VirtualizedItem", "Window", "CustomNavigation"
614
- )
615
-
616
- foreach ($pName in $patterns) {
617
- $propName = "Is" + $pName + "PatternAvailable"
618
- try {
619
- $prop = [AutomationElement]::($propName + "Property")
620
- $val = ${0}.GetCurrentPropertyValue($prop)
621
- $result[$propName] = $val.ToString()
622
- } catch {
623
- $result[$propName] = "False"
624
- }
625
- }
626
-
627
- # Pattern2 Compatibility (UIA 3.0)
628
- $result["IsTextPattern2Available"] = "False"
629
- $result["IsTransform2PatternAvailable"] = "False"
630
- $result["IsSelectionPattern2Available"] = "False"
631
-
632
- # 3. Pattern Specific Properties (Force Retrieval)
633
- $patternsToQuery = @{
634
- "Value" = @("Value", "IsReadOnly");
635
- "RangeValue" = @("Value", "IsReadOnly", "Minimum", "Maximum", "LargeChange", "SmallChange");
636
- "ExpandCollapse" = @("ExpandCollapseState");
637
- "Toggle" = @("ToggleState");
638
- "Window" = @("CanMaximize", "CanMinimize", "IsModal", "IsTopmost", "WindowInteractionState", "WindowVisualState");
639
- "Transform" = @("CanMove", "CanResize", "CanRotate");
640
- "Scroll" = @("HorizontalScrollPercent", "HorizontalViewSize", "VerticalScrollPercent", "VerticalViewSize", "HorizontallyScrollable", "VerticallyScrollable");
641
- "Selection" = @("CanSelectMultiple", "IsSelectionRequired");
642
- "SelectionItem" = @("IsSelected");
643
- "Grid" = @("ColumnCount", "RowCount");
644
- "GridItem" = @("Column", "Row", "ColumnSpan", "RowSpan");
645
- "Table" = @("RowOrColumnMajor");
646
- }
647
-
648
- foreach ($pKey in $patternsToQuery.Keys) {
649
- try {
650
- $pTypeName = "System.Windows.Automation.$($pKey)Pattern"
651
- $pPropField = Invoke-Expression "[$pTypeName]::Pattern"
652
- $pObj = ${0}.GetCurrentPattern($pPropField)
653
- if ($null -ne $pObj) {
654
- $result["Is" + $pKey + "PatternAvailable"] = "True"
655
- foreach ($propName in $patternsToQuery[$pKey]) {
656
- try {
657
- # Key used for dotted names in Inspect.exe
658
- $dottedKey = $pKey + "." + $propName
659
-
660
- # Try to get value from pattern object
661
- $val = $pObj.Current.$propName
662
- if ($null -ne $val) {
663
- $result[$dottedKey] = $val.ToString()
664
- # Also provide short name if not already set
665
- if (-not $result.ContainsKey($propName)) {
666
- $result[$propName] = $val.ToString()
667
- }
668
- }
669
- } catch {}
670
- }
671
- }
672
- } catch {}
673
- }
674
-
675
- # 4. Legacy Properties (Force Retrieval)
676
- try {
677
- $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current
678
- if ($null -ne $legacy) {
679
- $result["IsLegacyIAccessiblePatternAvailable"] = "True"
680
-
681
- # Standard Aliases (Backward Compatibility)
682
- $result['LegacyName'] = $legacy.Name
683
- $result['LegacyDescription'] = $legacy.Description
684
- $result['LegacyRole'] = $legacy.Role.ToString()
685
- $result['LegacyState'] = $legacy.State.ToString()
686
- $result['LegacyValue'] = $legacy.Value
687
- $result['LegacyHelp'] = $legacy.Help
688
- $result['LegacyKeyboardShortcut'] = $legacy.KeyboardShortcut
689
- $result['LegacyDefaultAction'] = $legacy.DefaultAction
690
- $result['LegacyChildId'] = $legacy.ChildId.ToString()
691
-
692
- # Dotted Names (Inspect.exe matching)
693
- $result['LegacyIAccessible.Name'] = $legacy.Name
694
- $result['LegacyIAccessible.Description'] = $legacy.Description
695
- $result['LegacyIAccessible.Role'] = $legacy.Role.ToString()
696
- $result['LegacyIAccessible.State'] = $legacy.State.ToString()
697
- $result['LegacyIAccessible.Value'] = $legacy.Value
698
- $result['LegacyIAccessible.Help'] = $legacy.Help
699
- $result['LegacyIAccessible.KeyboardShortcut'] = $legacy.KeyboardShortcut
700
- $result['LegacyIAccessible.DefaultAction'] = $legacy.DefaultAction
701
- $result['LegacyIAccessible.ChildId'] = $legacy.ChildId.ToString()
702
- }
703
- } catch {}
704
-
705
- # 5. GetSupportedProperties (Final sweep)
706
- try {
707
- foreach ($prop in ${0}.GetSupportedProperties()) {
708
- $name = $prop.ProgrammaticName.Split('.')[-1].Replace('Property', '')
709
- if (-not $result.ContainsKey($name)) {
710
- $val = ${0}.GetCurrentPropertyValue($prop)
711
- if ($null -ne $val) { $result[$name] = $val.ToString() }
712
- }
713
- }
714
- } catch {}
715
-
716
- $result | ConvertTo-Json -Compress
717
- }
558
+ const GET_ALL_ELEMENT_PROPERTIES = (0, core_1.pwsh$ /* ps1 */) `
559
+ if ($null -ne ${0}) {
560
+ $result = @{}
561
+
562
+ # 1. Standard Properties from AutomationElement
563
+ $standardProps = @(
564
+ "Name", "AutomationId", "ClassName", "ControlType", "LocalizedControlType",
565
+ "BoundingRectangle", "IsEnabled", "IsOffscreen", "IsKeyboardFocusable",
566
+ "HasKeyboardFocus", "AccessKey", "ProcessId", "RuntimeId", "FrameworkId",
567
+ "NativeWindowHandle", "IsContentElement", "IsControlElement", "IsPassword",
568
+ "HelpText", "ItemStatus", "ItemType", "AcceleratorKey"
569
+ )
570
+
571
+ foreach ($pName in $standardProps) {
572
+ try {
573
+ $prop = [AutomationElement]::($pName + "Property")
574
+ $val = ${0}.GetCurrentPropertyValue($prop)
575
+ if ($null -ne $val) {
576
+ if ($pName -eq "RuntimeId") { $result[$pName] = $val -join "." }
577
+ else { $result[$pName] = $val.ToString() }
578
+ }
579
+ } catch {}
580
+ }
581
+
582
+ # UIA 3.0+ Compatibility (Safe Defaults for UIA 2.0)
583
+ $result["IsDialog"] = "False"
584
+ $result["ProviderDescription"] = ""
585
+
586
+ # 2. Pattern Availability check
587
+ $patterns = @(
588
+ "Annotation", "Dock", "Drag", "DropTarget", "ExpandCollapse", "GridItem",
589
+ "Grid", "Invoke", "ItemContainer", "LegacyIAccessible", "MultipleView",
590
+ "ObjectModel", "RangeValue", "ScrollItem", "Scroll", "SelectionItem",
591
+ "Selection", "SpreadsheetItem", "Spreadsheet", "Styles", "SynchronizedInput",
592
+ "TableItem", "Table", "TextChild", "TextEdit", "Text", "Toggle", "Transform",
593
+ "Value", "VirtualizedItem", "Window", "CustomNavigation"
594
+ )
595
+
596
+ foreach ($pName in $patterns) {
597
+ $propName = "Is" + $pName + "PatternAvailable"
598
+ try {
599
+ $prop = [AutomationElement]::($propName + "Property")
600
+ $val = ${0}.GetCurrentPropertyValue($prop)
601
+ $result[$propName] = $val.ToString()
602
+ } catch {
603
+ $result[$propName] = "False"
604
+ }
605
+ }
606
+
607
+ # Pattern2 Compatibility (UIA 3.0)
608
+ $result["IsTextPattern2Available"] = "False"
609
+ $result["IsTransform2PatternAvailable"] = "False"
610
+ $result["IsSelectionPattern2Available"] = "False"
611
+
612
+ # 3. Pattern Specific Properties (Force Retrieval)
613
+ $patternsToQuery = @{
614
+ "Value" = @("Value", "IsReadOnly");
615
+ "RangeValue" = @("Value", "IsReadOnly", "Minimum", "Maximum", "LargeChange", "SmallChange");
616
+ "ExpandCollapse" = @("ExpandCollapseState");
617
+ "Toggle" = @("ToggleState");
618
+ "Window" = @("CanMaximize", "CanMinimize", "IsModal", "IsTopmost", "WindowInteractionState", "WindowVisualState");
619
+ "Transform" = @("CanMove", "CanResize", "CanRotate");
620
+ "Scroll" = @("HorizontalScrollPercent", "HorizontalViewSize", "VerticalScrollPercent", "VerticalViewSize", "HorizontallyScrollable", "VerticallyScrollable");
621
+ "Selection" = @("CanSelectMultiple", "IsSelectionRequired");
622
+ "SelectionItem" = @("IsSelected");
623
+ "Grid" = @("ColumnCount", "RowCount");
624
+ "GridItem" = @("Column", "Row", "ColumnSpan", "RowSpan");
625
+ "Table" = @("RowOrColumnMajor");
626
+ }
627
+
628
+ foreach ($pKey in $patternsToQuery.Keys) {
629
+ try {
630
+ $pTypeName = "System.Windows.Automation.$($pKey)Pattern"
631
+ $pPropField = Invoke-Expression "[$pTypeName]::Pattern"
632
+ $pObj = ${0}.GetCurrentPattern($pPropField)
633
+ if ($null -ne $pObj) {
634
+ $result["Is" + $pKey + "PatternAvailable"] = "True"
635
+ foreach ($propName in $patternsToQuery[$pKey]) {
636
+ try {
637
+ # Key used for dotted names in Inspect.exe
638
+ $dottedKey = $pKey + "." + $propName
639
+
640
+ # Try to get value from pattern object
641
+ $val = $pObj.Current.$propName
642
+ if ($null -ne $val) {
643
+ $result[$dottedKey] = $val.ToString()
644
+ # Also provide short name if not already set
645
+ if (-not $result.ContainsKey($propName)) {
646
+ $result[$propName] = $val.ToString()
647
+ }
648
+ }
649
+ } catch {}
650
+ }
651
+ }
652
+ } catch {}
653
+ }
654
+
655
+ # 4. Legacy Properties (Force Retrieval)
656
+ try {
657
+ $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current
658
+ if ($null -ne $legacy) {
659
+ $result["IsLegacyIAccessiblePatternAvailable"] = "True"
660
+
661
+ # Standard Aliases (Backward Compatibility)
662
+ $result['LegacyName'] = $legacy.Name
663
+ $result['LegacyDescription'] = $legacy.Description
664
+ $result['LegacyRole'] = $legacy.Role.ToString()
665
+ $result['LegacyState'] = $legacy.State.ToString()
666
+ $result['LegacyValue'] = $legacy.Value
667
+ $result['LegacyHelp'] = $legacy.Help
668
+ $result['LegacyKeyboardShortcut'] = $legacy.KeyboardShortcut
669
+ $result['LegacyDefaultAction'] = $legacy.DefaultAction
670
+ $result['LegacyChildId'] = $legacy.ChildId.ToString()
671
+
672
+ # Dotted Names (Inspect.exe matching)
673
+ $result['LegacyIAccessible.Name'] = $legacy.Name
674
+ $result['LegacyIAccessible.Description'] = $legacy.Description
675
+ $result['LegacyIAccessible.Role'] = $legacy.Role.ToString()
676
+ $result['LegacyIAccessible.State'] = $legacy.State.ToString()
677
+ $result['LegacyIAccessible.Value'] = $legacy.Value
678
+ $result['LegacyIAccessible.Help'] = $legacy.Help
679
+ $result['LegacyIAccessible.KeyboardShortcut'] = $legacy.KeyboardShortcut
680
+ $result['LegacyIAccessible.DefaultAction'] = $legacy.DefaultAction
681
+ $result['LegacyIAccessible.ChildId'] = $legacy.ChildId.ToString()
682
+ }
683
+ } catch {}
684
+
685
+ # 5. GetSupportedProperties (Final sweep)
686
+ try {
687
+ foreach ($prop in ${0}.GetSupportedProperties()) {
688
+ $name = $prop.ProgrammaticName.Split('.')[-1].Replace('Property', '')
689
+ if (-not $result.ContainsKey($name)) {
690
+ $val = ${0}.GetCurrentPropertyValue($prop)
691
+ if ($null -ne $val) { $result[$name] = $val.ToString() }
692
+ }
693
+ }
694
+ } catch {}
695
+
696
+ $result | ConvertTo-Json -Compress
697
+ }
718
698
  `;
719
699
  const SET_FOCUS_TO_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.SetFocus() }`;
720
- const GET_ELEMENT_TEXT = (0, core_1.pwsh$ /* ps1 */) `
721
- if ($null -ne ${0}) {
722
- try {
723
- ${0}.GetCurrentPattern([TextPattern]::Pattern).DocumentRange.GetText(-1)
724
- } catch {
725
- try {
726
- ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection().Current.Name
727
- } catch {
728
- ${0}.Current.Name
729
- }
730
- }
731
- }
700
+ const GET_ELEMENT_TEXT = (0, core_1.pwsh$ /* ps1 */) `
701
+ if ($null -ne ${0}) {
702
+ try {
703
+ ${0}.GetCurrentPattern([TextPattern]::Pattern).DocumentRange.GetText(-1)
704
+ } catch {
705
+ try {
706
+ ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection().Current.Name
707
+ } catch {
708
+ ${0}.Current.Name
709
+ }
710
+ }
711
+ }
732
712
  `;
733
713
  const INVOKE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([InvokePattern]::Pattern).Invoke() }`;
734
714
  const EXPAND_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Expand() }`;
735
715
  const COLLAPSE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Collapse() }`;
736
- const SCROLL_ELEMENT_INTO_VIEW = (0, core_1.pwsh$ /* ps1 */) `
737
- if ($null -ne ${0}) {
738
- $pattern = ${0}.GetCurrentPattern([ScrollItemPattern]::Pattern);
739
- if ($null -ne $pattern) {
740
- $pattern.ScrollIntoView()
741
- } else {
742
- $success = $false
743
- try {
744
- ${0}.SetFocus()
745
- $success = $true
746
- } catch {}
747
-
748
- if (-not $success) {
749
- try {
750
- $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern);
751
- if ($null -ne $legacy) {
752
- $legacy.Select(3);
753
- $success = $true
754
- }
755
- } catch {}
756
- }
757
-
758
- if (-not $success) {
759
- # Try ItemContainerPattern on parent
760
- try {
761
- $parent = [TreeWalker]::ControlViewWalker.GetParent(${0});
762
- if ($null -ne $parent) {
763
- $containerPattern = $parent.GetCurrentPattern([ItemContainerPattern]::Pattern);
764
- if ($null -ne $containerPattern) {
765
- # We have the element, so we pass it directly to be realized/scrolled to
766
- $found = $containerPattern.FindItemByProperty($null, [AutomationElement]::RuntimeIdProperty, ${0}.GetRuntimeId());
767
- if ($null -ne $found) {
768
- # Accessing the found item usually brings it into view or realizes it?
769
- # Actually FindItemByProperty returns the element. We might need to ScrollIntoView THAT element?
770
- # But we already have the element. The docs say "retrieves an element... and scrolls it into view".
771
- $success = $true
772
- }
773
- }
774
- }
775
- } catch {}
776
- }
777
-
778
- if (-not $success) {
779
- throw "Failed to scroll into view: ScrollItemPattern not supported, and SetFocus/LegacySelect/ItemContainerPattern failed."
780
- }
781
- }
782
- }
716
+ const SCROLL_ELEMENT_INTO_VIEW = (0, core_1.pwsh$ /* ps1 */) `
717
+ if ($null -ne ${0}) {
718
+ $pattern = ${0}.GetCurrentPattern([ScrollItemPattern]::Pattern);
719
+ if ($null -ne $pattern) {
720
+ $pattern.ScrollIntoView()
721
+ } else {
722
+ $success = $false
723
+ try {
724
+ ${0}.SetFocus()
725
+ $success = $true
726
+ } catch {}
727
+
728
+ if (-not $success) {
729
+ try {
730
+ $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern);
731
+ if ($null -ne $legacy) {
732
+ $legacy.Select(3);
733
+ $success = $true
734
+ }
735
+ } catch {}
736
+ }
737
+
738
+ if (-not $success) {
739
+ # Try ItemContainerPattern on parent
740
+ try {
741
+ $parent = [TreeWalker]::ControlViewWalker.GetParent(${0});
742
+ if ($null -ne $parent) {
743
+ $containerPattern = $parent.GetCurrentPattern([ItemContainerPattern]::Pattern);
744
+ if ($null -ne $containerPattern) {
745
+ # We have the element, so we pass it directly to be realized/scrolled to
746
+ $found = $containerPattern.FindItemByProperty($null, [AutomationElement]::RuntimeIdProperty, ${0}.GetRuntimeId());
747
+ if ($null -ne $found) {
748
+ # Accessing the found item usually brings it into view or realizes it?
749
+ # Actually FindItemByProperty returns the element. We might need to ScrollIntoView THAT element?
750
+ # But we already have the element. The docs say "retrieves an element... and scrolls it into view".
751
+ $success = $true
752
+ }
753
+ }
754
+ }
755
+ } catch {}
756
+ }
757
+
758
+ if (-not $success) {
759
+ throw "Failed to scroll into view: ScrollItemPattern not supported, and SetFocus/LegacySelect/ItemContainerPattern failed."
760
+ }
761
+ }
762
+ }
783
763
  `;
784
764
  const IS_MULTIPLE_SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.CanSelectMultiple }`;
785
765
  const GET_SELECTED_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection() }`;
@@ -788,63 +768,63 @@ const ADD_ELEMENT_TO_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}
788
768
  const REMOVE_ELEMENT_FROM_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).RemoveFromSelection() }`;
789
769
  const SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).Select() }`;
790
770
  const TOGGLE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Toggle() }`;
791
- const SET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
792
- if ($null -ne ${0}) {
793
- try {
794
- ${0}.GetCurrentPattern([ValuePattern]::Pattern).SetValue(${1})
795
- } catch {
796
- try {
797
- $hwnd = ${0}.Current.NativeWindowHandle
798
- if ($hwnd -gt 0) {
799
- [MSAAHelper]::SetLegacyValue([IntPtr]$hwnd, ${1})
800
- }
801
- } catch {}
802
- }
803
- }
771
+ const SET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
772
+ if ($null -ne ${0}) {
773
+ try {
774
+ ${0}.GetCurrentPattern([ValuePattern]::Pattern).SetValue(${1})
775
+ } catch {
776
+ try {
777
+ $hwnd = ${0}.Current.NativeWindowHandle
778
+ if ($hwnd -gt 0) {
779
+ [MSAAHelper]::SetLegacyValue([IntPtr]$hwnd, ${1})
780
+ }
781
+ } catch {}
782
+ }
783
+ }
804
784
  `;
805
- const GET_ELEMENT_EXPAND_COLLAPSE_STATE = (0, core_1.pwsh$ /* ps1 */) `
806
- if ($null -ne ${0}) {
807
- try {
808
- ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Current.ExpandCollapseState
809
- } catch { $null }
810
- }
785
+ const GET_ELEMENT_EXPAND_COLLAPSE_STATE = (0, core_1.pwsh$ /* ps1 */) `
786
+ if ($null -ne ${0}) {
787
+ try {
788
+ ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Current.ExpandCollapseState
789
+ } catch { $null }
790
+ }
811
791
  `;
812
792
  const SET_ELEMENT_RANGE_VALUE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([RangeValuePattern]::Pattern).SetValue(${1}) }`;
813
- const GET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
814
- if ($null -ne ${0}) {
815
- try {
816
- ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.Value
817
- } catch {
818
- try {
819
- $hwnd = ${0}.Current.NativeWindowHandle
820
- if ($hwnd -gt 0) {
821
- [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
822
- } else { $null }
823
- } catch { $null }
824
- }
825
- }
793
+ const GET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
794
+ if ($null -ne ${0}) {
795
+ try {
796
+ ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.Value
797
+ } catch {
798
+ try {
799
+ $hwnd = ${0}.Current.NativeWindowHandle
800
+ if ($hwnd -gt 0) {
801
+ [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
802
+ } else { $null }
803
+ } catch { $null }
804
+ }
805
+ }
826
806
  `;
827
- const GET_ELEMENT_VALUE_IS_READ_ONLY = (0, core_1.pwsh$ /* ps1 */) `
828
- if ($null -ne ${0}) {
829
- try {
830
- ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.IsReadOnly
831
- } catch {
832
- # Fallback for Value Pattern missing via MSAA?
833
- # MSAA doesn't strictly have IsReadOnly, but if accValue is settable?
834
- # accState includes generic STATE_SYSTEM_READONLY?
835
- try {
836
- $hwnd = ${0}.Current.NativeWindowHandle
837
- if ($hwnd -gt 0) {
838
- $props = [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState");
839
- # Check bitwise unique? PowerShell casting might strictly return string or object.
840
- # But GetLegacyProperty returns object (int usually for state, but MSAAHelper does implicit reflection).
841
- # Wait, MSAAHelper uses InvokeMember. accState returns Int32? Or specific I4?
842
- # Let's assume it returns something usable.
843
- $null
844
- } else { $null }
845
- } catch { $null }
846
- }
847
- }
807
+ const GET_ELEMENT_VALUE_IS_READ_ONLY = (0, core_1.pwsh$ /* ps1 */) `
808
+ if ($null -ne ${0}) {
809
+ try {
810
+ ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.IsReadOnly
811
+ } catch {
812
+ # Fallback for Value Pattern missing via MSAA?
813
+ # MSAA doesn't strictly have IsReadOnly, but if accValue is settable?
814
+ # accState includes generic STATE_SYSTEM_READONLY?
815
+ try {
816
+ $hwnd = ${0}.Current.NativeWindowHandle
817
+ if ($hwnd -gt 0) {
818
+ $props = [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState");
819
+ # Check bitwise unique? PowerShell casting might strictly return string or object.
820
+ # But GetLegacyProperty returns object (int usually for state, but MSAAHelper does implicit reflection).
821
+ # Wait, MSAAHelper uses InvokeMember. accState returns Int32? Or specific I4?
822
+ # Let's assume it returns something usable.
823
+ $null
824
+ } else { $null }
825
+ } catch { $null }
826
+ }
827
+ }
848
828
  `;
849
829
  const GET_ELEMENT_TOGGLE_STATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Current.ToggleState }`;
850
830
  const MAXIMIZE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([WindowPattern]::Pattern).SetWindowVisualState([WindowVisualState]::Maximized) }`;