appium-novawindows2-driver 0.2.7 → 0.2.9
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.
- package/build/lib/commands/functions.d.ts.map +1 -1
- package/build/lib/commands/functions.js +37 -1
- package/build/lib/commands/functions.js.map +1 -1
- package/build/lib/commands/index.d.ts +3 -3
- package/build/lib/commands/powershell.d.ts.map +1 -1
- package/build/lib/commands/powershell.js +17 -11
- package/build/lib/commands/powershell.js.map +1 -1
- package/build/lib/powershell/elements.d.ts.map +1 -1
- package/build/lib/powershell/elements.js +390 -379
- package/build/lib/powershell/elements.js.map +1 -1
- package/build/lib/powershell/msaa.d.ts.map +1 -1
- package/build/lib/powershell/msaa.js +86 -17
- package/build/lib/powershell/msaa.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -252,10 +252,10 @@ const FIND_ALL_CHILDREN_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
|
|
|
252
252
|
|
|
253
253
|
Write-Output $els
|
|
254
254
|
`;
|
|
255
|
-
const FIND_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `
|
|
256
|
-
const FIND_ALL_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `
|
|
257
|
-
const FIND_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
|
|
258
|
-
const FIND_ALL_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `
|
|
255
|
+
const FIND_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `Find-ChildrenRecursively -element (${0}) -condition (${1})`;
|
|
256
|
+
const FIND_ALL_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `Find-AllChildrenRecursively -element (${0}) -condition (${1})`;
|
|
257
|
+
const FIND_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `Find-ChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true`;
|
|
258
|
+
const FIND_ALL_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `Find-AllChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true`;
|
|
259
259
|
const FIND_FIRST = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.FindFirst([TreeScope]::${1}, ${2}) }`;
|
|
260
260
|
const FIND_ALL = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.FindAll([TreeScope]::${1}, ${2}) }`;
|
|
261
261
|
const AUTOMATION_ROOT = /* ps1 */ `$rootElement`;
|
|
@@ -263,13 +263,17 @@ const FOCUSED_ELEMENT = /* ps1 */ `[AutomationElement]::FocusedElement`;
|
|
|
263
263
|
const ROOT_ELEMENT = /* ps1 */ `[AutomationElement]::RootElement`;
|
|
264
264
|
const SAVE_TO_ELEMENT_TABLE_AND_RETURN_ID = (0, core_1.pwsh$ /* ps1 */) `
|
|
265
265
|
${0} | Where-Object { $null -ne $_ } | ForEach-Object {
|
|
266
|
-
|
|
266
|
+
try {
|
|
267
|
+
$runtimeId = $_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.';
|
|
267
268
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
if (-not $elementTable.ContainsKey($runtimeId)) {
|
|
270
|
+
$elementTable.Add($runtimeId, $_)
|
|
271
|
+
};
|
|
271
272
|
|
|
272
|
-
|
|
273
|
+
$runtimeId
|
|
274
|
+
} catch {
|
|
275
|
+
# ElementNotAvailableException
|
|
276
|
+
}
|
|
273
277
|
}
|
|
274
278
|
`;
|
|
275
279
|
const ELEMENT_TABLE_GET = (0, core_1.pwsh$ /* ps1 */) `
|
|
@@ -380,7 +384,11 @@ const GET_ELEMENT_PROPERTY = (0, core_1.pwsh$ /* ps1 */) `
|
|
|
380
384
|
`;
|
|
381
385
|
const GET_ELEMENT_RUNTIME_ID = (0, core_1.pwsh$ /* ps1 */) `
|
|
382
386
|
${0} | Where-Object { $null -ne $_ } | ForEach-Object {
|
|
383
|
-
|
|
387
|
+
try {
|
|
388
|
+
$_.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.'
|
|
389
|
+
} catch {
|
|
390
|
+
# ElementNotAvailableException
|
|
391
|
+
}
|
|
384
392
|
}
|
|
385
393
|
`;
|
|
386
394
|
const GET_ELEMENT_RECT = (0, core_1.pwsh$ /* ps1 */) `
|
|
@@ -393,173 +401,137 @@ const GET_ELEMENT_RECT = (0, core_1.pwsh$ /* ps1 */) `
|
|
|
393
401
|
}
|
|
394
402
|
`;
|
|
395
403
|
const GET_ELEMENT_LEGACY_VALUE = (0, core_1.pwsh$ /* ps1 */) `
|
|
396
|
-
|
|
397
|
-
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Value
|
|
398
|
-
} catch {
|
|
399
|
-
try {
|
|
400
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
401
|
-
if ($hwnd -gt 0) {
|
|
402
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
|
|
403
|
-
} else { $null }
|
|
404
|
-
} catch { $null }
|
|
405
|
-
}
|
|
404
|
+
Get-LegacyPropertySafe -element ${0} -propName "Value" -accPropName "accValue"
|
|
406
405
|
`;
|
|
407
406
|
const GET_ELEMENT_LEGACY_NAME = (0, core_1.pwsh$ /* ps1 */) `
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
} catch {
|
|
412
|
-
try {
|
|
413
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
414
|
-
if ($hwnd -gt 0) {
|
|
415
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accName")
|
|
416
|
-
} else { $null }
|
|
417
|
-
} catch { $null }
|
|
418
|
-
}
|
|
419
|
-
}
|
|
407
|
+
$val = Get-LegacyPropertySafe -element ${0} -propName "Name" -accPropName "accName"
|
|
408
|
+
if ($null -eq $val) { $val = ${0}.Current.Name }
|
|
409
|
+
$val
|
|
420
410
|
`;
|
|
421
411
|
const GET_ELEMENT_LEGACY_DESCRIPTION = (0, core_1.pwsh$ /* ps1 */) `
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
} catch {
|
|
426
|
-
try {
|
|
427
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
428
|
-
if ($hwnd -gt 0) {
|
|
429
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDescription")
|
|
430
|
-
} else { $null }
|
|
431
|
-
} catch { $null }
|
|
432
|
-
}
|
|
433
|
-
}
|
|
412
|
+
$val = Get-LegacyPropertySafe -element ${0} -propName "Description" -accPropName "accDescription"
|
|
413
|
+
if ($null -eq $val) { $val = ${0}.Current.HelpText }
|
|
414
|
+
$val
|
|
434
415
|
`;
|
|
435
416
|
const GET_ELEMENT_LEGACY_ROLE = (0, core_1.pwsh$ /* ps1 */) `
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
} catch {
|
|
440
|
-
try {
|
|
441
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
442
|
-
if ($hwnd -gt 0) {
|
|
443
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accRole")
|
|
444
|
-
} else { $null }
|
|
445
|
-
} catch { $null }
|
|
446
|
-
}
|
|
447
|
-
}
|
|
417
|
+
$val = Get-LegacyPropertySafe -element ${0} -propName "Role" -accPropName "accRole"
|
|
418
|
+
if ($null -eq $val) { $val = ${0}.Current.LocalizedControlType }
|
|
419
|
+
$val
|
|
448
420
|
`;
|
|
449
421
|
const GET_ELEMENT_LEGACY_STATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
450
422
|
if ($null -ne ${0}) {
|
|
451
|
-
|
|
452
|
-
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.State
|
|
453
|
-
} catch {
|
|
454
|
-
try {
|
|
455
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
456
|
-
if ($hwnd -gt 0) {
|
|
457
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState")
|
|
458
|
-
} else { $null }
|
|
459
|
-
} catch { $null }
|
|
460
|
-
}
|
|
423
|
+
Get-LegacyPropertySafe -element ${0} -propName "State" -accPropName "accState"
|
|
461
424
|
}
|
|
462
425
|
`;
|
|
463
426
|
const GET_ELEMENT_LEGACY_HELP = (0, core_1.pwsh$ /* ps1 */) `
|
|
464
427
|
if ($null -ne ${0}) {
|
|
465
|
-
|
|
466
|
-
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Help
|
|
467
|
-
} catch {
|
|
468
|
-
try {
|
|
469
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
470
|
-
if ($hwnd -gt 0) {
|
|
471
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accHelp")
|
|
472
|
-
} else { $null }
|
|
473
|
-
} catch { $null }
|
|
474
|
-
}
|
|
428
|
+
Get-LegacyPropertySafe -element ${0} -propName "Help" -accPropName "accHelp"
|
|
475
429
|
}
|
|
476
430
|
`;
|
|
477
431
|
const GET_ELEMENT_LEGACY_KEYBOARD_SHORTCUT = (0, core_1.pwsh$ /* ps1 */) `
|
|
478
432
|
if ($null -ne ${0}) {
|
|
479
|
-
|
|
480
|
-
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.KeyboardShortcut
|
|
481
|
-
} catch {
|
|
482
|
-
try {
|
|
483
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
484
|
-
if ($hwnd -gt 0) {
|
|
485
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accKeyboardShortcut")
|
|
486
|
-
} else { $null }
|
|
487
|
-
} catch { $null }
|
|
488
|
-
}
|
|
433
|
+
Get-LegacyPropertySafe -element ${0} -propName "KeyboardShortcut" -accPropName "accKeyboardShortcut"
|
|
489
434
|
}
|
|
490
435
|
`;
|
|
491
436
|
const GET_ELEMENT_LEGACY_DEFAULT_ACTION = (0, core_1.pwsh$ /* ps1 */) `
|
|
492
437
|
if ($null -ne ${0}) {
|
|
493
|
-
|
|
494
|
-
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.DefaultAction
|
|
495
|
-
} catch {
|
|
496
|
-
try {
|
|
497
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
498
|
-
if ($hwnd -gt 0) {
|
|
499
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accDefaultAction")
|
|
500
|
-
} else { $null }
|
|
501
|
-
} catch { $null }
|
|
502
|
-
}
|
|
438
|
+
Get-LegacyPropertySafe -element ${0} -propName "DefaultAction" -accPropName "accDefaultAction"
|
|
503
439
|
}
|
|
504
440
|
`;
|
|
505
|
-
const GET_ELEMENT_WINDOW_CAN_MAXIMIZE = (0, core_1.pwsh$ /* ps1 */) `
|
|
506
|
-
const GET_ELEMENT_WINDOW_CAN_MINIMIZE = (0, core_1.pwsh$ /* ps1 */) `
|
|
507
|
-
const GET_ELEMENT_WINDOW_IS_MODAL = (0, core_1.pwsh$ /* ps1 */) `
|
|
508
|
-
const GET_ELEMENT_WINDOW_IS_TOPMOST = (0, core_1.pwsh$ /* ps1 */) `
|
|
509
|
-
const GET_ELEMENT_WINDOW_INTERACTION_STATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
510
|
-
const GET_ELEMENT_WINDOW_VISUAL_STATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
511
|
-
const GET_ELEMENT_TRANSFORM_CAN_MOVE = (0, core_1.pwsh$ /* ps1 */) `
|
|
512
|
-
const GET_ELEMENT_TRANSFORM_CAN_RESIZE = (0, core_1.pwsh$ /* ps1 */) `
|
|
513
|
-
const GET_ELEMENT_TRANSFORM_CAN_ROTATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
441
|
+
const GET_ELEMENT_WINDOW_CAN_MAXIMIZE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMaximize } catch { $null }`;
|
|
442
|
+
const GET_ELEMENT_WINDOW_CAN_MINIMIZE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMinimize } catch { $null }`;
|
|
443
|
+
const GET_ELEMENT_WINDOW_IS_MODAL = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.IsModal } catch { $null }`;
|
|
444
|
+
const GET_ELEMENT_WINDOW_IS_TOPMOST = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.IsTopmost } catch { $null }`;
|
|
445
|
+
const GET_ELEMENT_WINDOW_INTERACTION_STATE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.WindowInteractionState.ToString() } catch { $null }`;
|
|
446
|
+
const GET_ELEMENT_WINDOW_VISUAL_STATE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.WindowVisualState.ToString() } catch { $null }`;
|
|
447
|
+
const GET_ELEMENT_TRANSFORM_CAN_MOVE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanMove } catch { $null }`;
|
|
448
|
+
const GET_ELEMENT_TRANSFORM_CAN_RESIZE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanResize } catch { $null }`;
|
|
449
|
+
const GET_ELEMENT_TRANSFORM_CAN_ROTATE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanRotate } catch { $null }`;
|
|
514
450
|
const GET_ELEMENT_LEGACY_CHILD_ID = (0, core_1.pwsh$ /* ps1 */) `
|
|
515
|
-
|
|
451
|
+
if ($null -ne ${0}) {
|
|
452
|
+
try {
|
|
453
|
+
${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.ChildId
|
|
454
|
+
} catch {
|
|
455
|
+
# For HWND based elements, ChildId is usually 0
|
|
516
456
|
try {
|
|
517
|
-
${0}.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
457
|
+
$rect = ${0}.Current.BoundingRectangle
|
|
458
|
+
if ($null -ne $rect -and $rect.Width -gt 0) {
|
|
459
|
+
$cx = [int]($rect.Left + $rect.Width / 2)
|
|
460
|
+
$cy = [int]($rect.Top + $rect.Height / 2)
|
|
461
|
+
$props = [MSAAHelper]::GetLegacyPropsFromPoint($cx, $cy)
|
|
462
|
+
$props["ChildId"]
|
|
463
|
+
} else {
|
|
464
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
465
|
+
if ($hwnd -gt 0) {
|
|
466
|
+
0
|
|
467
|
+
} else { $null }
|
|
468
|
+
}
|
|
469
|
+
} catch { $null }
|
|
527
470
|
}
|
|
471
|
+
}
|
|
528
472
|
`;
|
|
529
473
|
const IS_LEGACY_PATTERN_AVAILABLE = (0, core_1.pwsh$ /* ps1 */) `
|
|
530
|
-
|
|
474
|
+
if ($null -ne ${0}) {
|
|
475
|
+
try {
|
|
476
|
+
if ($null -ne ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern)) {
|
|
477
|
+
$true
|
|
478
|
+
} else {
|
|
479
|
+
# Only check HWND / Point if managed pattern retrieval explicitly failed / returned null
|
|
480
|
+
$result = $false
|
|
481
|
+
try {
|
|
482
|
+
$rect = ${0}.Current.BoundingRectangle
|
|
483
|
+
if ($null -ne $rect -and $rect.Width -gt 0) {
|
|
484
|
+
$cx = [int]($rect.Left + $rect.Width / 2)
|
|
485
|
+
$cy = [int]($rect.Top + $rect.Height / 2)
|
|
486
|
+
$props = [MSAAHelper]::GetLegacyPropsFromPoint($cx, $cy)
|
|
487
|
+
if ($null -ne $props) { $result = $true }
|
|
488
|
+
}
|
|
489
|
+
} catch { }
|
|
490
|
+
|
|
491
|
+
if (-not $result) {
|
|
492
|
+
try {
|
|
493
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
494
|
+
if ($hwnd -gt 0) { $result = $true }
|
|
495
|
+
} catch { }
|
|
496
|
+
}
|
|
497
|
+
$result
|
|
498
|
+
}
|
|
499
|
+
} catch {
|
|
500
|
+
# Fallback for TypeNotFound or other UIA errors
|
|
501
|
+
$result = $false
|
|
531
502
|
try {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
$hwnd = ${0}.Current.NativeWindowHandle
|
|
539
|
-
$hwnd -gt 0
|
|
503
|
+
$rect = ${0}.Current.BoundingRectangle
|
|
504
|
+
if ($null -ne $rect -and $rect.Width -gt 0) {
|
|
505
|
+
$cx = [int]($rect.Left + $rect.Width / 2)
|
|
506
|
+
$cy = [int]($rect.Top + $rect.Height / 2)
|
|
507
|
+
$props = [MSAAHelper]::GetLegacyPropsFromPoint($cx, $cy)
|
|
508
|
+
if ($null -ne $props) { $result = $true }
|
|
540
509
|
}
|
|
541
|
-
} catch {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
510
|
+
} catch { }
|
|
511
|
+
|
|
512
|
+
if (-not $result) {
|
|
513
|
+
try {
|
|
514
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
515
|
+
if ($hwnd -gt 0) { $result = $true }
|
|
516
|
+
} catch { }
|
|
547
517
|
}
|
|
548
|
-
|
|
549
|
-
$false
|
|
518
|
+
$result
|
|
550
519
|
}
|
|
520
|
+
} else {
|
|
521
|
+
$false
|
|
522
|
+
}
|
|
551
523
|
`;
|
|
552
524
|
const GET_ELEMENT_TAG_NAME = (0, core_1.pwsh$ /* ps1 */) `
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
525
|
+
if ($null -ne ${0}) {
|
|
526
|
+
try { $ct = ${0}.Cached.ControlType } catch { $ct = ${0}.Current.ControlType }
|
|
527
|
+
$ct.ProgrammaticName |
|
|
556
528
|
ForEach-Object {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
529
|
+
$type = $_.Split('.')[-1]
|
|
530
|
+
if ($type -eq 'DataGrid') { 'List' }
|
|
531
|
+
elseif($type -eq 'DataItem') { 'ListItem' }
|
|
532
|
+
else { $type }
|
|
562
533
|
}
|
|
534
|
+
}
|
|
563
535
|
`;
|
|
564
536
|
// ... (rest of file)
|
|
565
537
|
// Inside AutomationElement class (implicit connection via line numbers, I will target the class method efficiently)
|
|
@@ -567,280 +539,319 @@ const GET_ELEMENT_TAG_NAME = (0, core_1.pwsh$ /* ps1 */) `
|
|
|
567
539
|
// The replace tool works on line ranges. I will convert this to 2 separate edits or use multi_replace.
|
|
568
540
|
// Let's use multi_replace for cleaner insertion.
|
|
569
541
|
const GET_ALL_ELEMENT_PROPERTIES = (0, core_1.pwsh$ /* ps1 */) `
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
} catch {}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
# UIA 3.0+ Compatibility (Safe Defaults for UIA 2.0)
|
|
594
|
-
$result["IsDialog"] = "False"
|
|
595
|
-
$result["ProviderDescription"] = ""
|
|
596
|
-
|
|
597
|
-
# 2. Pattern Availability check
|
|
598
|
-
$patterns = @(
|
|
599
|
-
"Annotation", "Dock", "Drag", "DropTarget", "ExpandCollapse", "GridItem",
|
|
600
|
-
"Grid", "Invoke", "ItemContainer", "LegacyIAccessible", "MultipleView",
|
|
601
|
-
"ObjectModel", "RangeValue", "ScrollItem", "Scroll", "SelectionItem",
|
|
602
|
-
"Selection", "SpreadsheetItem", "Spreadsheet", "Styles", "SynchronizedInput",
|
|
603
|
-
"TableItem", "Table", "TextChild", "TextEdit", "Text", "Toggle", "Transform",
|
|
604
|
-
"Value", "VirtualizedItem", "Window", "CustomNavigation"
|
|
605
|
-
)
|
|
606
|
-
|
|
607
|
-
foreach ($pName in $patterns) {
|
|
608
|
-
$propName = "Is" + $pName + "PatternAvailable"
|
|
609
|
-
try {
|
|
610
|
-
$prop = [AutomationElement]::($propName + "Property")
|
|
611
|
-
$val = ${0}.GetCurrentPropertyValue($prop)
|
|
612
|
-
$result[$propName] = $val.ToString()
|
|
613
|
-
} catch {
|
|
614
|
-
$result[$propName] = "False"
|
|
542
|
+
if ($null -ne ${0}) {
|
|
543
|
+
$result = @{}
|
|
544
|
+
|
|
545
|
+
# 1. Standard Properties from AutomationElement
|
|
546
|
+
$standardProps = @(
|
|
547
|
+
"Name", "AutomationId", "ClassName", "ControlType", "LocalizedControlType",
|
|
548
|
+
"BoundingRectangle", "IsEnabled", "IsOffscreen", "IsKeyboardFocusable",
|
|
549
|
+
"HasKeyboardFocus", "AccessKey", "ProcessId", "RuntimeId", "FrameworkId",
|
|
550
|
+
"NativeWindowHandle", "IsContentElement", "IsControlElement", "IsPassword",
|
|
551
|
+
"HelpText", "ItemStatus", "ItemType", "AcceleratorKey"
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
foreach($pName in $standardProps) {
|
|
555
|
+
try {
|
|
556
|
+
$prop = [AutomationElement]::($pName + "Property")
|
|
557
|
+
$val = ${0}.GetCurrentPropertyValue($prop)
|
|
558
|
+
if ($null -ne $val) {
|
|
559
|
+
if ($pName -eq "RuntimeId") { $result[$pName] = $val -join "." }
|
|
560
|
+
else { $result[$pName] = $val.ToString() }
|
|
615
561
|
}
|
|
562
|
+
} catch { }
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
# UIA 3.0 + Compatibility(Safe Defaults for UIA 2.0)
|
|
566
|
+
$result["IsDialog"] = "False"
|
|
567
|
+
$result["ProviderDescription"] = ""
|
|
568
|
+
|
|
569
|
+
# 2. Pattern Availability check
|
|
570
|
+
$patterns = @(
|
|
571
|
+
"Annotation", "Dock", "Drag", "DropTarget", "ExpandCollapse", "GridItem",
|
|
572
|
+
"Grid", "Invoke", "ItemContainer", "LegacyIAccessible", "MultipleView",
|
|
573
|
+
"ObjectModel", "RangeValue", "ScrollItem", "Scroll", "SelectionItem",
|
|
574
|
+
"Selection", "SpreadsheetItem", "Spreadsheet", "Styles", "SynchronizedInput",
|
|
575
|
+
"TableItem", "Table", "TextChild", "TextEdit", "Text", "Toggle", "Transform",
|
|
576
|
+
"Value", "VirtualizedItem", "Window", "CustomNavigation"
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
foreach($pName in $patterns) {
|
|
580
|
+
$propName = "Is" + $pName + "PatternAvailable"
|
|
581
|
+
try {
|
|
582
|
+
$prop = [AutomationElement]::($propName + "Property")
|
|
583
|
+
$val = ${0}.GetCurrentPropertyValue($prop)
|
|
584
|
+
$result[$propName] = $val.ToString()
|
|
585
|
+
} catch {
|
|
586
|
+
$result[$propName] = "False"
|
|
616
587
|
}
|
|
617
|
-
|
|
618
|
-
# Pattern2 Compatibility (UIA 3.0)
|
|
619
|
-
$result["IsTextPattern2Available"] = "False"
|
|
620
|
-
$result["IsTransform2PatternAvailable"] = "False"
|
|
621
|
-
$result["IsSelectionPattern2Available"] = "False"
|
|
622
|
-
|
|
623
|
-
# 3. Pattern Specific Properties (Force Retrieval)
|
|
624
|
-
$patternsToQuery = @{
|
|
625
|
-
"Value" = @("Value", "IsReadOnly");
|
|
626
|
-
"RangeValue" = @("Value", "IsReadOnly", "Minimum", "Maximum", "LargeChange", "SmallChange");
|
|
627
|
-
"ExpandCollapse" = @("ExpandCollapseState");
|
|
628
|
-
"Toggle" = @("ToggleState");
|
|
629
|
-
"Window" = @("CanMaximize", "CanMinimize", "IsModal", "IsTopmost", "WindowInteractionState", "WindowVisualState");
|
|
630
|
-
"Transform" = @("CanMove", "CanResize", "CanRotate");
|
|
631
|
-
"Scroll" = @("HorizontalScrollPercent", "HorizontalViewSize", "VerticalScrollPercent", "VerticalViewSize", "HorizontallyScrollable", "VerticallyScrollable");
|
|
632
|
-
"Selection" = @("CanSelectMultiple", "IsSelectionRequired");
|
|
633
|
-
"SelectionItem" = @("IsSelected");
|
|
634
|
-
"Grid" = @("ColumnCount", "RowCount");
|
|
635
|
-
"GridItem" = @("Column", "Row", "ColumnSpan", "RowSpan");
|
|
636
|
-
"Table" = @("RowOrColumnMajor");
|
|
637
|
-
}
|
|
588
|
+
}
|
|
638
589
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
590
|
+
# Pattern2 Compatibility(UIA 3.0)
|
|
591
|
+
$result["IsTextPattern2Available"] = "False"
|
|
592
|
+
$result["IsTransform2PatternAvailable"] = "False"
|
|
593
|
+
$result["IsSelectionPattern2Available"] = "False"
|
|
594
|
+
|
|
595
|
+
# 3. Pattern Specific Properties(Force Retrieval)
|
|
596
|
+
$patternsToQuery = @{
|
|
597
|
+
"Value" = @("Value", "IsReadOnly");
|
|
598
|
+
"RangeValue" = @("Value", "IsReadOnly", "Minimum", "Maximum", "LargeChange", "SmallChange");
|
|
599
|
+
"ExpandCollapse" = @("ExpandCollapseState");
|
|
600
|
+
"Toggle" = @("ToggleState");
|
|
601
|
+
"Window" = @("CanMaximize", "CanMinimize", "IsModal", "IsTopmost", "WindowInteractionState", "WindowVisualState");
|
|
602
|
+
"Transform" = @("CanMove", "CanResize", "CanRotate");
|
|
603
|
+
"Scroll" = @("HorizontalScrollPercent", "HorizontalViewSize", "VerticalScrollPercent", "VerticalViewSize", "HorizontallyScrollable", "VerticallyScrollable");
|
|
604
|
+
"Selection" = @("CanSelectMultiple", "IsSelectionRequired");
|
|
605
|
+
"SelectionItem" = @("IsSelected");
|
|
606
|
+
"Grid" = @("ColumnCount", "RowCount");
|
|
607
|
+
"GridItem" = @("Column", "Row", "ColumnSpan", "RowSpan");
|
|
608
|
+
"Table" = @("RowOrColumnMajor");
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
foreach($pKey in $patternsToQuery.Keys) {
|
|
612
|
+
try {
|
|
613
|
+
$pTypeName = "System.Windows.Automation.$($pKey)Pattern"
|
|
614
|
+
$pPropField = Invoke-Expression "[$pTypeName]::Pattern"
|
|
615
|
+
$pObj = ${0}.GetCurrentPattern($pPropField)
|
|
616
|
+
if ($null -ne $pObj) {
|
|
617
|
+
$result["Is" + $pKey + "PatternAvailable"] = "True"
|
|
618
|
+
foreach($propName in $patternsToQuery[$pKey]) {
|
|
619
|
+
try {
|
|
648
620
|
# Key used for dotted names in Inspect.exe
|
|
649
621
|
$dottedKey = $pKey + "." + $propName
|
|
650
622
|
|
|
651
623
|
# Try to get value from pattern object
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
624
|
+
$val = $pObj.Current.$propName
|
|
625
|
+
if ($null -ne $val) {
|
|
626
|
+
$result[$dottedKey] = $val.ToString()
|
|
655
627
|
# Also provide short name if not already set
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
628
|
+
if (-not $result.ContainsKey($propName)) {
|
|
629
|
+
$result[$propName] = $val.ToString()
|
|
659
630
|
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
631
|
+
}
|
|
632
|
+
} catch { }
|
|
662
633
|
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
634
|
+
}
|
|
635
|
+
} catch { }
|
|
636
|
+
}
|
|
665
637
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
638
|
+
# 4. Legacy Properties(Force Retrieval)
|
|
639
|
+
try {
|
|
640
|
+
$legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current
|
|
641
|
+
if ($null -ne $legacy) {
|
|
642
|
+
$result["IsLegacyIAccessiblePatternAvailable"] = "True"
|
|
671
643
|
|
|
672
|
-
# Standard Aliases
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
# Dotted Names
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
644
|
+
# Standard Aliases(Backward Compatibility)
|
|
645
|
+
$result['LegacyName'] = $legacy.Name
|
|
646
|
+
$result['LegacyDescription'] = $legacy.Description
|
|
647
|
+
$result['LegacyRole'] = $legacy.Role.ToString()
|
|
648
|
+
$result['LegacyState'] = $legacy.State.ToString()
|
|
649
|
+
$result['LegacyValue'] = $legacy.Value
|
|
650
|
+
$result['LegacyHelp'] = $legacy.Help
|
|
651
|
+
$result['LegacyKeyboardShortcut'] = $legacy.KeyboardShortcut
|
|
652
|
+
$result['LegacyDefaultAction'] = $legacy.DefaultAction
|
|
653
|
+
$result['LegacyChildId'] = $legacy.ChildId.ToString()
|
|
654
|
+
|
|
655
|
+
# Dotted Names(Inspect.exe matching)
|
|
656
|
+
$result['LegacyIAccessible.Name'] = $legacy.Name
|
|
657
|
+
$result['LegacyIAccessible.Description'] = $legacy.Description
|
|
658
|
+
$result['LegacyIAccessible.Role'] = $legacy.Role.ToString()
|
|
659
|
+
$result['LegacyIAccessible.State'] = $legacy.State.ToString()
|
|
660
|
+
$result['LegacyIAccessible.Value'] = $legacy.Value
|
|
661
|
+
$result['LegacyIAccessible.Help'] = $legacy.Help
|
|
662
|
+
$result['LegacyIAccessible.KeyboardShortcut'] = $legacy.KeyboardShortcut
|
|
663
|
+
$result['LegacyIAccessible.DefaultAction'] = $legacy.DefaultAction
|
|
664
|
+
$result['LegacyIAccessible.ChildId'] = $legacy.ChildId.ToString()
|
|
665
|
+
}
|
|
666
|
+
} catch { }
|
|
667
|
+
|
|
668
|
+
# MSAA Fallback
|
|
669
|
+
try {
|
|
670
|
+
$msaaProps = $null
|
|
671
|
+
$rect = ${0}.Current.BoundingRectangle
|
|
672
|
+
|
|
673
|
+
# Check if rect is valid / not - empty to calculate center for Point lookup
|
|
674
|
+
if ($null -ne $rect -and $rect.Width -gt 0 -and $rect.Height -gt 0) {
|
|
675
|
+
$cx = [int]($rect.Left + ($rect.Width / 2))
|
|
676
|
+
$cy = [int]($rect.Top + ($rect.Height / 2))
|
|
677
|
+
$msaaProps = [MSAAHelper]::GetLegacyPropsFromPoint($cx, $cy)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
# Fallback to HWND if Point lookup didn't work or rect was empty (e.g. offscreen?)
|
|
681
|
+
if ($null -eq $msaaProps) {
|
|
682
|
+
if ($result.ContainsKey("NativeWindowHandle")) {
|
|
683
|
+
$hwnd = $result["NativeWindowHandle"]
|
|
684
|
+
} else {
|
|
685
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
693
686
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
687
|
+
if ($hwnd -ne 0) {
|
|
688
|
+
$msaaProps = [MSAAHelper]::GetAllLegacyProperties([IntPtr]$hwnd)
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if ($null -ne $msaaProps) {
|
|
693
|
+
# If we found props via MSAA(Point or HWND), mark pattern as available
|
|
694
|
+
$result["IsLegacyIAccessiblePatternAvailable"] = "True"
|
|
695
|
+
foreach($key in $msaaProps.Keys) {
|
|
696
|
+
$val = $msaaProps[$key]
|
|
697
|
+
if ($null -ne $val) {
|
|
698
|
+
# Inspect.exe style: LegacyIAccessible.Name
|
|
699
|
+
$result["LegacyIAccessible." + $key] = $val
|
|
700
|
+
# Driver Internal Alias: LegacyName
|
|
701
|
+
$result["Legacy" + $key] = $val
|
|
703
702
|
}
|
|
704
703
|
}
|
|
705
|
-
}
|
|
704
|
+
}
|
|
705
|
+
} catch { }
|
|
706
706
|
|
|
707
|
-
|
|
708
|
-
|
|
707
|
+
# 5. GetSupportedProperties(Final sweep)
|
|
708
|
+
try {
|
|
709
|
+
foreach($prop in ${0}.GetSupportedProperties()) {
|
|
710
|
+
$name = $prop.ProgrammaticName.Split('.')[-1].Replace('Property', '')
|
|
711
|
+
if (-not $result.ContainsKey($name)) {
|
|
712
|
+
$val = ${0}.GetCurrentPropertyValue($prop)
|
|
713
|
+
if ($null -ne $val) { $result[$name] = $val.ToString() }
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
} catch { }
|
|
717
|
+
|
|
718
|
+
$result | ConvertTo-Json -Compress
|
|
719
|
+
}
|
|
709
720
|
`;
|
|
710
|
-
const SET_FOCUS_TO_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.SetFocus() }`;
|
|
721
|
+
const SET_FOCUS_TO_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.SetFocus() } `;
|
|
711
722
|
const GET_ELEMENT_TEXT = (0, core_1.pwsh$ /* ps1 */) `
|
|
712
|
-
|
|
723
|
+
if ($null -ne ${0}) {
|
|
724
|
+
try {
|
|
725
|
+
${0}.GetCurrentPattern([TextPattern]::Pattern).DocumentRange.GetText(-1)
|
|
726
|
+
} catch {
|
|
713
727
|
try {
|
|
714
|
-
${0}.GetCurrentPattern([
|
|
728
|
+
${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection().Current.Name
|
|
715
729
|
} catch {
|
|
716
|
-
|
|
717
|
-
${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection().Current.Name
|
|
718
|
-
} catch {
|
|
719
|
-
${0}.Current.Name
|
|
720
|
-
}
|
|
730
|
+
${0}.Current.Name
|
|
721
731
|
}
|
|
722
732
|
}
|
|
733
|
+
}
|
|
723
734
|
`;
|
|
724
|
-
const INVOKE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([InvokePattern]::Pattern).Invoke() }`;
|
|
725
|
-
const EXPAND_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Expand() }`;
|
|
726
|
-
const COLLAPSE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Collapse() }`;
|
|
735
|
+
const INVOKE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([InvokePattern]::Pattern).Invoke() } `;
|
|
736
|
+
const EXPAND_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Expand() } `;
|
|
737
|
+
const COLLAPSE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Collapse() } `;
|
|
727
738
|
const SCROLL_ELEMENT_INTO_VIEW = (0, core_1.pwsh$ /* ps1 */) `
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
739
|
+
if ($null -ne ${0}) {
|
|
740
|
+
$pattern = ${0}.GetCurrentPattern([ScrollItemPattern]::Pattern);
|
|
741
|
+
if ($null -ne $pattern) {
|
|
742
|
+
$pattern.ScrollIntoView()
|
|
743
|
+
} else {
|
|
744
|
+
$success = $false
|
|
745
|
+
try {
|
|
746
|
+
${0}.SetFocus()
|
|
747
|
+
$success = $true
|
|
748
|
+
} catch { }
|
|
738
749
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
750
|
+
if (-not $success) {
|
|
751
|
+
try {
|
|
752
|
+
$legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern);
|
|
753
|
+
if ($null -ne $legacy) {
|
|
754
|
+
$legacy.Select(3);
|
|
755
|
+
$success = $true
|
|
756
|
+
}
|
|
757
|
+
} catch { }
|
|
758
|
+
}
|
|
748
759
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
760
|
+
if (-not $success) {
|
|
761
|
+
# Try ItemContainerPattern on parent
|
|
762
|
+
try {
|
|
763
|
+
$parent = [TreeWalker]::ControlViewWalker.GetParent(${0});
|
|
764
|
+
if ($null -ne $parent) {
|
|
765
|
+
$containerPattern = $parent.GetCurrentPattern([ItemContainerPattern]::Pattern);
|
|
766
|
+
if ($null -ne $containerPattern) {
|
|
767
|
+
# We have the element, so we pass it directly to be realized / scrolled to
|
|
768
|
+
$found = $containerPattern.FindItemByProperty($null, [AutomationElement]::RuntimeIdProperty, ${0}.GetRuntimeId());
|
|
769
|
+
if ($null -ne $found) {
|
|
770
|
+
# Accessing the found item usually brings it into view or realizes it ?
|
|
771
|
+
# Actually FindItemByProperty returns the element.We might need to ScrollIntoView THAT element ?
|
|
772
|
+
# But we already have the element.The docs say "retrieves an element... and scrolls it into view".
|
|
773
|
+
$success = $true
|
|
764
774
|
}
|
|
765
775
|
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
776
|
+
}
|
|
777
|
+
} catch { }
|
|
778
|
+
}
|
|
768
779
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
780
|
+
if (-not $success) {
|
|
781
|
+
throw "Failed to scroll into view: ScrollItemPattern not supported, and SetFocus/LegacySelect/ItemContainerPattern failed."
|
|
772
782
|
}
|
|
773
783
|
}
|
|
784
|
+
}
|
|
774
785
|
`;
|
|
775
|
-
const IS_MULTIPLE_SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.CanSelectMultiple }`;
|
|
776
|
-
const GET_SELECTED_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection() }`;
|
|
777
|
-
const IS_ELEMENT_SELECTED = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).Current.IsSelected }`;
|
|
778
|
-
const ADD_ELEMENT_TO_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).AddToSelection() }`;
|
|
779
|
-
const REMOVE_ELEMENT_FROM_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).RemoveFromSelection() }`;
|
|
780
|
-
const SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).Select() }`;
|
|
781
|
-
const TOGGLE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Toggle() }`;
|
|
786
|
+
const IS_MULTIPLE_SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.CanSelectMultiple } `;
|
|
787
|
+
const GET_SELECTED_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection() } `;
|
|
788
|
+
const IS_ELEMENT_SELECTED = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).Current.IsSelected } `;
|
|
789
|
+
const ADD_ELEMENT_TO_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).AddToSelection() } `;
|
|
790
|
+
const REMOVE_ELEMENT_FROM_SELECTION = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).RemoveFromSelection() } `;
|
|
791
|
+
const SELECT_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([SelectionItemPattern]::Pattern).Select() } `;
|
|
792
|
+
const TOGGLE_ELEMENT = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Toggle() } `;
|
|
782
793
|
const SET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
|
|
783
|
-
|
|
794
|
+
if ($null -ne ${0}) {
|
|
795
|
+
try {
|
|
796
|
+
${0}.GetCurrentPattern([ValuePattern]::Pattern).SetValue(${1})
|
|
797
|
+
} catch {
|
|
784
798
|
try {
|
|
785
|
-
${0}.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
[MSAAHelper]::SetLegacyValue([IntPtr]$hwnd, ${1})
|
|
791
|
-
}
|
|
792
|
-
} catch {}
|
|
793
|
-
}
|
|
799
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
800
|
+
if ($hwnd -gt 0) {
|
|
801
|
+
[MSAAHelper]::SetLegacyValue([IntPtr]$hwnd, ${1})
|
|
802
|
+
}
|
|
803
|
+
} catch { }
|
|
794
804
|
}
|
|
805
|
+
}
|
|
795
806
|
`;
|
|
796
807
|
const GET_ELEMENT_EXPAND_COLLAPSE_STATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
808
|
+
if ($null -ne ${0}) {
|
|
809
|
+
try {
|
|
810
|
+
${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Current.ExpandCollapseState
|
|
811
|
+
} catch { $null }
|
|
812
|
+
}
|
|
802
813
|
`;
|
|
803
|
-
const SET_ELEMENT_RANGE_VALUE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([RangeValuePattern]::Pattern).SetValue(${1}) }`;
|
|
814
|
+
const SET_ELEMENT_RANGE_VALUE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([RangeValuePattern]::Pattern).SetValue(${1}) } `;
|
|
804
815
|
const GET_ELEMENT_VALUE = (0, core_1.pwsh$ /* ps1 */) `
|
|
805
|
-
|
|
816
|
+
if ($null -ne ${0}) {
|
|
817
|
+
try {
|
|
818
|
+
${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.Value
|
|
819
|
+
} catch {
|
|
806
820
|
try {
|
|
807
|
-
${0}.
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
|
|
813
|
-
} else { $null }
|
|
814
|
-
} catch { $null }
|
|
815
|
-
}
|
|
821
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
822
|
+
if ($hwnd -gt 0) {
|
|
823
|
+
[MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accValue")
|
|
824
|
+
} else { $null }
|
|
825
|
+
} catch { $null }
|
|
816
826
|
}
|
|
827
|
+
}
|
|
817
828
|
`;
|
|
818
829
|
const GET_ELEMENT_VALUE_IS_READ_ONLY = (0, core_1.pwsh$ /* ps1 */) `
|
|
819
|
-
|
|
830
|
+
if ($null -ne ${0}) {
|
|
831
|
+
try {
|
|
832
|
+
${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.IsReadOnly
|
|
833
|
+
} catch {
|
|
834
|
+
# Fallback for Value Pattern missing via MSAA ?
|
|
835
|
+
# MSAA doesn't strictly have IsReadOnly, but if accValue is settable?
|
|
836
|
+
# accState includes generic STATE_SYSTEM_READONLY(0x40) ?
|
|
820
837
|
try {
|
|
821
|
-
${0}.
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
if ($null -ne $state) {
|
|
831
|
-
# STATE_SYSTEM_READONLY = 0x40 (64)
|
|
832
|
-
($state -band 64) -eq 64
|
|
833
|
-
} else { $false }
|
|
834
|
-
} else { $false }
|
|
835
|
-
} catch { $false }
|
|
836
|
-
}
|
|
838
|
+
$hwnd = ${0}.Current.NativeWindowHandle
|
|
839
|
+
if ($hwnd -gt 0) {
|
|
840
|
+
$state = [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState");
|
|
841
|
+
if ($null -ne $state) {
|
|
842
|
+
# STATE_SYSTEM_READONLY = 0x40(64)
|
|
843
|
+
($state -band 64) -eq 64
|
|
844
|
+
} else { $false }
|
|
845
|
+
} else { $false }
|
|
846
|
+
} catch { $false }
|
|
837
847
|
}
|
|
848
|
+
}
|
|
838
849
|
`;
|
|
839
|
-
const GET_ELEMENT_TOGGLE_STATE = (0, core_1.pwsh$ /* ps1 */) `
|
|
840
|
-
const MAXIMIZE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) {
|
|
841
|
-
const MINIMIZE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) {
|
|
842
|
-
const RESTORE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) {
|
|
843
|
-
const CLOSE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) {
|
|
850
|
+
const GET_ELEMENT_TOGGLE_STATE = (0, core_1.pwsh$ /* ps1 */) `try { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Current.ToggleState } catch { $null }`;
|
|
851
|
+
const MAXIMIZE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([WindowPattern]::Pattern).SetWindowVisualState([WindowVisualState]::Maximized) }`;
|
|
852
|
+
const MINIMIZE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([WindowPattern]::Pattern).SetWindowVisualState([WindowVisualState]::Minimized) }`;
|
|
853
|
+
const RESTORE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([WindowPattern]::Pattern).SetWindowVisualState([WindowVisualState]::Normal) }`;
|
|
854
|
+
const CLOSE_WINDOW = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Close() }`;
|
|
844
855
|
exports.TreeScope = Object.freeze({
|
|
845
856
|
ANCESTORS_OR_SELF: 'ancestors-or-self',
|
|
846
857
|
FOLLOWING: 'following',
|
|
@@ -946,31 +957,31 @@ class AutomationElement extends core_1.PSObject {
|
|
|
946
957
|
if (property.toLowerCase() === 'controltype') {
|
|
947
958
|
return GET_ELEMENT_TAG_NAME.format(this);
|
|
948
959
|
}
|
|
949
|
-
if (property.toLowerCase() === 'legacyvalue') {
|
|
960
|
+
if (property.toLowerCase() === 'legacyvalue' || property.toLowerCase() === 'legacyiaccessible.value') {
|
|
950
961
|
return GET_ELEMENT_LEGACY_VALUE.format(this);
|
|
951
962
|
}
|
|
952
|
-
if (property.toLowerCase() === 'legacyname') {
|
|
963
|
+
if (property.toLowerCase() === 'legacyname' || property.toLowerCase() === 'legacyiaccessible.name') {
|
|
953
964
|
return GET_ELEMENT_LEGACY_NAME.format(this);
|
|
954
965
|
}
|
|
955
|
-
if (property.toLowerCase() === 'legacydescription') {
|
|
966
|
+
if (property.toLowerCase() === 'legacydescription' || property.toLowerCase() === 'legacyiaccessible.description') {
|
|
956
967
|
return GET_ELEMENT_LEGACY_DESCRIPTION.format(this);
|
|
957
968
|
}
|
|
958
|
-
if (property.toLowerCase() === 'legacyrole') {
|
|
969
|
+
if (property.toLowerCase() === 'legacyrole' || property.toLowerCase() === 'legacyiaccessible.role') {
|
|
959
970
|
return GET_ELEMENT_LEGACY_ROLE.format(this);
|
|
960
971
|
}
|
|
961
|
-
if (property.toLowerCase() === 'legacystate') {
|
|
972
|
+
if (property.toLowerCase() === 'legacystate' || property.toLowerCase() === 'legacyiaccessible.state') {
|
|
962
973
|
return GET_ELEMENT_LEGACY_STATE.format(this);
|
|
963
974
|
}
|
|
964
|
-
if (property.toLowerCase() === 'legacyhelp') {
|
|
975
|
+
if (property.toLowerCase() === 'legacyhelp' || property.toLowerCase() === 'legacyiaccessible.help') {
|
|
965
976
|
return GET_ELEMENT_LEGACY_HELP.format(this);
|
|
966
977
|
}
|
|
967
|
-
if (property.toLowerCase() === 'legacykeyboardshortcut') {
|
|
978
|
+
if (property.toLowerCase() === 'legacykeyboardshortcut' || property.toLowerCase() === 'legacyiaccessible.keyboardshortcut') {
|
|
968
979
|
return GET_ELEMENT_LEGACY_KEYBOARD_SHORTCUT.format(this);
|
|
969
980
|
}
|
|
970
|
-
if (property.toLowerCase() === 'legacydefaultaction') {
|
|
981
|
+
if (property.toLowerCase() === 'legacydefaultaction' || property.toLowerCase() === 'legacyiaccessible.defaultaction') {
|
|
971
982
|
return GET_ELEMENT_LEGACY_DEFAULT_ACTION.format(this);
|
|
972
983
|
}
|
|
973
|
-
if (property.toLowerCase() === 'legacychildid') {
|
|
984
|
+
if (property.toLowerCase() === 'legacychildid' || property.toLowerCase() === 'legacyiaccessible.childid') {
|
|
974
985
|
return GET_ELEMENT_LEGACY_CHILD_ID.format(this);
|
|
975
986
|
}
|
|
976
987
|
if (property.toLowerCase() === 'islegacyiaccessiblepatternavailable') {
|
|
@@ -1054,7 +1065,7 @@ exports.AutomationElement = AutomationElement;
|
|
|
1054
1065
|
class AutomationElementGroup extends AutomationElement {
|
|
1055
1066
|
groups;
|
|
1056
1067
|
constructor(...automationElements) {
|
|
1057
|
-
super(`@(
|
|
1068
|
+
super(`@(${automationElements.map((el) => `(${el.buildCommand()})`).join(', ')} )`);
|
|
1058
1069
|
this.groups = automationElements;
|
|
1059
1070
|
}
|
|
1060
1071
|
findAllGroups(scope, condition) {
|