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.
@@ -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 */) `if ($null -ne ${0}) { Find-ChildrenRecursively -element (${0}) -condition (${1}) }`;
256
- const FIND_ALL_DESCENDANTS = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { Find-AllChildrenRecursively -element (${0}) -condition (${1}) }`;
257
- const FIND_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { Find-ChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true }`;
258
- const FIND_ALL_DESCENDANTS_OR_SELF = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { Find-AllChildrenRecursively -element (${0}) -condition (${1}) -includeSelf $true }`;
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
- try {
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
- if ($null -ne ${0}) {
409
- try {
410
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Name
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
- if ($null -ne ${0}) {
423
- try {
424
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Description
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
- if ($null -ne ${0}) {
437
- try {
438
- ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.Role
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
- try {
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
- try {
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
- try {
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
- try {
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 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMaximize } catch { $null } }`;
506
- const GET_ELEMENT_WINDOW_CAN_MINIMIZE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.CanMinimize } catch { $null } }`;
507
- const GET_ELEMENT_WINDOW_IS_MODAL = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.IsModal } catch { $null } }`;
508
- const GET_ELEMENT_WINDOW_IS_TOPMOST = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.IsTopmost } catch { $null } }`;
509
- const GET_ELEMENT_WINDOW_INTERACTION_STATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.WindowInteractionState.ToString() } catch { $null } }`;
510
- const GET_ELEMENT_WINDOW_VISUAL_STATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([WindowPattern]::Pattern).Current.WindowVisualState.ToString() } catch { $null } }`;
511
- const GET_ELEMENT_TRANSFORM_CAN_MOVE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanMove } catch { $null } }`;
512
- const GET_ELEMENT_TRANSFORM_CAN_RESIZE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanResize } catch { $null } }`;
513
- const GET_ELEMENT_TRANSFORM_CAN_ROTATE = (0, core_1.pwsh$ /* ps1 */) `if ($null -ne ${0}) { try { ${0}.GetCurrentPattern([TransformPattern]::Pattern).Current.CanRotate } catch { $null } }`;
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
- if ($null -ne ${0}) {
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}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current.ChildId
518
- } catch {
519
- # For HWND based elements, ChildId is usually 0
520
- try {
521
- $hwnd = ${0}.Current.NativeWindowHandle
522
- if ($hwnd -gt 0) {
523
- 0
524
- } else { $null }
525
- } catch { $null }
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
- if ($null -ne ${0}) {
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
- if ($null -ne ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern)) {
533
- $true
534
- } else {
535
- # Only check HWND if managed pattern retrieval explicitly failed/returned null, but we are inside try block
536
- # Actually if GetCurrentPattern throws, we go to catch.
537
- # If it returns null (not supported), we go to else.
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
- # Fallback for TypeNotFound or other UIA errors
543
- try {
544
- $hwnd = ${0}.Current.NativeWindowHandle
545
- $hwnd -gt 0
546
- } catch { $false }
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
- } else {
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
- if ($null -ne ${0}) {
554
- try { $ct = ${0}.Cached.ControlType } catch { $ct = ${0}.Current.ControlType }
555
- $ct.ProgrammaticName |
517
+ if ($null -ne ${0}) {
518
+ try { $ct = ${0}.Cached.ControlType } catch { $ct = ${0}.Current.ControlType }
519
+ $ct.ProgrammaticName |
556
520
  ForEach-Object {
557
- $type = $_.Split('.')[-1]
558
- if ($type -eq 'DataGrid') { 'List' }
559
- elseif ($type -eq 'DataItem') { 'ListItem' }
560
- else { $type }
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
- if ($null -ne ${0}) {
571
- $result = @{}
572
-
573
- # 1. Standard Properties from AutomationElement
574
- $standardProps = @(
575
- "Name", "AutomationId", "ClassName", "ControlType", "LocalizedControlType",
576
- "BoundingRectangle", "IsEnabled", "IsOffscreen", "IsKeyboardFocusable",
577
- "HasKeyboardFocus", "AccessKey", "ProcessId", "RuntimeId", "FrameworkId",
578
- "NativeWindowHandle", "IsContentElement", "IsControlElement", "IsPassword",
579
- "HelpText", "ItemStatus", "ItemType", "AcceleratorKey"
580
- )
581
-
582
- foreach ($pName in $standardProps) {
583
- try {
584
- $prop = [AutomationElement]::($pName + "Property")
585
- $val = ${0}.GetCurrentPropertyValue($prop)
586
- if ($null -ne $val) {
587
- if ($pName -eq "RuntimeId") { $result[$pName] = $val -join "." }
588
- else { $result[$pName] = $val.ToString() }
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
- foreach ($pKey in $patternsToQuery.Keys) {
640
- try {
641
- $pTypeName = "System.Windows.Automation.$($pKey)Pattern"
642
- $pPropField = Invoke-Expression "[$pTypeName]::Pattern"
643
- $pObj = ${0}.GetCurrentPattern($pPropField)
644
- if ($null -ne $pObj) {
645
- $result["Is" + $pKey + "PatternAvailable"] = "True"
646
- foreach ($propName in $patternsToQuery[$pKey]) {
647
- try {
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
- $val = $pObj.Current.$propName
653
- if ($null -ne $val) {
654
- $result[$dottedKey] = $val.ToString()
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
- if (-not $result.ContainsKey($propName)) {
657
- $result[$propName] = $val.ToString()
658
- }
620
+ if (-not $result.ContainsKey($propName)) {
621
+ $result[$propName] = $val.ToString()
659
622
  }
660
- } catch {}
661
- }
623
+ }
624
+ } catch { }
662
625
  }
663
- } catch {}
664
- }
626
+ }
627
+ } catch { }
628
+ }
665
629
 
666
- # 4. Legacy Properties (Force Retrieval)
667
- try {
668
- $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern).Current
669
- if ($null -ne $legacy) {
670
- $result["IsLegacyIAccessiblePatternAvailable"] = "True"
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 (Backward Compatibility)
673
- $result['LegacyName'] = $legacy.Name
674
- $result['LegacyDescription'] = $legacy.Description
675
- $result['LegacyRole'] = $legacy.Role.ToString()
676
- $result['LegacyState'] = $legacy.State.ToString()
677
- $result['LegacyValue'] = $legacy.Value
678
- $result['LegacyHelp'] = $legacy.Help
679
- $result['LegacyKeyboardShortcut'] = $legacy.KeyboardShortcut
680
- $result['LegacyDefaultAction'] = $legacy.DefaultAction
681
- $result['LegacyChildId'] = $legacy.ChildId.ToString()
682
-
683
- # Dotted Names (Inspect.exe matching)
684
- $result['LegacyIAccessible.Name'] = $legacy.Name
685
- $result['LegacyIAccessible.Description'] = $legacy.Description
686
- $result['LegacyIAccessible.Role'] = $legacy.Role.ToString()
687
- $result['LegacyIAccessible.State'] = $legacy.State.ToString()
688
- $result['LegacyIAccessible.Value'] = $legacy.Value
689
- $result['LegacyIAccessible.Help'] = $legacy.Help
690
- $result['LegacyIAccessible.KeyboardShortcut'] = $legacy.KeyboardShortcut
691
- $result['LegacyIAccessible.DefaultAction'] = $legacy.DefaultAction
692
- $result['LegacyIAccessible.ChildId'] = $legacy.ChildId.ToString()
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
- } catch {}
695
-
696
- # 5. GetSupportedProperties (Final sweep)
697
- try {
698
- foreach ($prop in ${0}.GetSupportedProperties()) {
699
- $name = $prop.ProgrammaticName.Split('.')[-1].Replace('Property', '')
700
- if (-not $result.ContainsKey($name)) {
701
- $val = ${0}.GetCurrentPropertyValue($prop)
702
- if ($null -ne $val) { $result[$name] = $val.ToString() }
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
- } catch {}
696
+ }
697
+ } catch { }
706
698
 
707
- $result | ConvertTo-Json -Compress
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
- if ($null -ne ${0}) {
715
+ if ($null -ne ${0}) {
716
+ try {
717
+ ${0}.GetCurrentPattern([TextPattern]::Pattern).DocumentRange.GetText(-1)
718
+ } catch {
713
719
  try {
714
- ${0}.GetCurrentPattern([TextPattern]::Pattern).DocumentRange.GetText(-1)
720
+ ${0}.GetCurrentPattern([SelectionPattern]::Pattern).Current.GetSelection().Current.Name
715
721
  } catch {
716
- try {
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
- if ($null -ne ${0}) {
729
- $pattern = ${0}.GetCurrentPattern([ScrollItemPattern]::Pattern);
730
- if ($null -ne $pattern) {
731
- $pattern.ScrollIntoView()
732
- } else {
733
- $success = $false
734
- try {
735
- ${0}.SetFocus()
736
- $success = $true
737
- } catch {}
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
- if (-not $success) {
740
- try {
741
- $legacy = ${0}.GetCurrentPattern([System.Windows.Automation.LegacyIAccessiblePattern]::Pattern);
742
- if ($null -ne $legacy) {
743
- $legacy.Select(3);
744
- $success = $true
745
- }
746
- } catch {}
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
- if (-not $success) {
750
- # Try ItemContainerPattern on parent
751
- try {
752
- $parent = [TreeWalker]::ControlViewWalker.GetParent(${0});
753
- if ($null -ne $parent) {
754
- $containerPattern = $parent.GetCurrentPattern([ItemContainerPattern]::Pattern);
755
- if ($null -ne $containerPattern) {
756
- # We have the element, so we pass it directly to be realized/scrolled to
757
- $found = $containerPattern.FindItemByProperty($null, [AutomationElement]::RuntimeIdProperty, ${0}.GetRuntimeId());
758
- if ($null -ne $found) {
759
- # Accessing the found item usually brings it into view or realizes it?
760
- # Actually FindItemByProperty returns the element. We might need to ScrollIntoView THAT element?
761
- # But we already have the element. The docs say "retrieves an element... and scrolls it into view".
762
- $success = $true
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
- } catch {}
767
- }
768
+ }
769
+ } catch { }
770
+ }
768
771
 
769
- if (-not $success) {
770
- throw "Failed to scroll into view: ScrollItemPattern not supported, and SetFocus/LegacySelect/ItemContainerPattern failed."
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
- if ($null -ne ${0}) {
786
+ if ($null -ne ${0}) {
787
+ try {
788
+ ${0}.GetCurrentPattern([ValuePattern]::Pattern).SetValue(${1})
789
+ } catch {
784
790
  try {
785
- ${0}.GetCurrentPattern([ValuePattern]::Pattern).SetValue(${1})
786
- } catch {
787
- try {
788
- $hwnd = ${0}.Current.NativeWindowHandle
789
- if ($hwnd -gt 0) {
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
- if ($null -ne ${0}) {
798
- try {
799
- ${0}.GetCurrentPattern([ExpandCollapsePattern]::Pattern).Current.ExpandCollapseState
800
- } catch { $null }
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
- if ($null -ne ${0}) {
808
+ if ($null -ne ${0}) {
809
+ try {
810
+ ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.Value
811
+ } catch {
806
812
  try {
807
- ${0}.GetCurrentPattern([ValuePattern]::Pattern).Current.Value
808
- } catch {
809
- try {
810
- $hwnd = ${0}.Current.NativeWindowHandle
811
- if ($hwnd -gt 0) {
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
- if ($null -ne ${0}) {
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}.GetCurrentPattern([ValuePattern]::Pattern).Current.IsReadOnly
822
- } catch {
823
- # Fallback for Value Pattern missing via MSAA?
824
- # MSAA doesn't strictly have IsReadOnly, but if accValue is settable?
825
- # accState includes generic STATE_SYSTEM_READONLY (0x40)?
826
- try {
827
- $hwnd = ${0}.Current.NativeWindowHandle
828
- if ($hwnd -gt 0) {
829
- $state = [MSAAHelper]::GetLegacyProperty([IntPtr]$hwnd, "accState");
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 */) `if ($null -ne ${0}) { ${0}.GetCurrentPattern([TogglePattern]::Pattern).Current.ToggleState }`;
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(`@( ${automationElements.map((el) => `(${el.buildCommand()})`).join(', ')} )`);
1060
+ super(`@(${automationElements.map((el) => `(${el.buildCommand()})`).join(', ')} )`);
1058
1061
  this.groups = automationElements;
1059
1062
  }
1060
1063
  findAllGroups(scope, condition) {