yinkaisheng / Python-UIAutomation-for-Windows

🐍Python 3 wrapper of Microsoft UIAutomation. Support UIAutomation for MFC, WindowsForm, WPF, Modern UI(Metro UI), Qt, IE, Firefox, Chrome ...
Apache License 2.0
2.3k stars 462 forks source link

无法获取NTQQ的窗口 #270

Closed Bi2Nb9O3-Studio closed 4 months ago

Bi2Nb9O3-Studio commented 4 months ago

已将敏感信息替换为#ERASE# 实际内容完全一致 系统环境:UIAutomation 2.0.18 (Python 3.11.4, 64 bit) Windows 11 23H2(22635.3139) 查询输出:

UIAutomation 2.0.18 (Python 3.11.4, 64 bit)
please wait for 3 seconds

2024-02-12 00:40:14.614 automation.py[80] main -> Starts, Current Cursor Position: (1578, 1310)
ControlType: PaneControl    ClassName: #32769    AutomationId:     Rect: (0,0,2256,1504)[2256x1504]    Name: '桌面 1'    Handle: 0x10010(65552)    Depth: 0    ProcessId: 1180    SupportedPattern: LegacyIAccessiblePattern
    ControlType: PaneControl    ClassName: Chrome_WidgetWin_1    AutomationId:     Rect: (-9,-9,2265,1453)[2274x1462]    Name: '#ERASE#'    Handle: 0x110F38(1118008)    Depth: 1    ProcessId: 348    SupportedPattern: LegacyIAccessiblePattern ScrollItemPattern TransformPattern WindowPattern
        ControlType: DocumentControl    ClassName: Chrome_RenderWidgetHostHWND    AutomationId: 21625280    Rect: (0,0,2257,1445)[2257x1445]    Name: ''    Handle: 0xF0AE8(985832)    Depth: 2    ProcessId: 348    ScrollPattern.HorizontalScrollPercent: 0.0    ScrollPattern.VerticalScrollPercent: 0.0    TextPattern.Text: '         #ERASE# '    ValuePattern.Value: 'app://./renderer/index.html?webcontentsid=16&processGroupNS=createBlankWindow1#/chat'    SupportedPattern: LegacyIAccessiblePattern ScrollItemPattern ScrollPattern TextPattern TextPattern2 ValuePattern
            ControlType: GroupControl    ClassName:     AutomationId:     Rect: (0,0,2257,1445)[2257x1445]    Name: ''    Handle: 0x0(0)    Depth: 3    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                ControlType: GroupControl    ClassName:     AutomationId: app    Rect: (0,0,2257,1445)[2257x1445]    Name: ''    Handle: 0x0(0)    Depth: 4    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                    ControlType: GroupControl    ClassName:     AutomationId:     Rect: (0,0,2257,1445)[2257x1445]    Name: ''    Handle: 0x0(0)    Depth: 5    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                        ControlType: GroupControl    ClassName:     AutomationId:     Rect: (0,1186,2032,1445)[2032x259]    Name: ''    Handle: 0x0(0)    Depth: 6    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                            ControlType: GroupControl    ClassName:     AutomationId:     Rect: (0,1226,2032,1375)[2032x149]    Name: ''    Handle: 0x0(0)    Depth: 7    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                                ControlType: WindowControl    ClassName:     AutomationId:     Rect: (0,1226,2032,1374)[2032x148]    Name: 'Rich Text Editor'    Handle: 0x0(0)    Depth: 8    ProcessId: 348    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern
                                    ControlType: EditControl    ClassName:     AutomationId:     Rect: (0,1226,2032,1374)[2032x148]    Name: '#ERASE#'    Handle: 0x0(0)    Depth: 9    ProcessId: 348    TextPattern.Text: '你好q! '    ValuePattern.Value: '你好q!'    SupportedPattern: InvokePattern LegacyIAccessiblePattern ScrollItemPattern TextChildPattern TextEditPattern TextPattern TextPattern2 ValuePattern

Python代码:

import uiautomation as auto
auto.uiautomation.SetGlobalSearchTimeout(30)
window = auto.PaneControl(searchDepth=1,Handle=1118008)
print(window)

期待输出:QQ窗口信息 实际输出:

Bi2Nb9O3-Studio commented 4 months ago

解决方案:管理员运行