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