Python-UIAutomation-for-Windows icon indicating copy to clipboard operation
Python-UIAutomation-for-Windows copied to clipboard

不能定位到QQ窗口的控件

Open Louis-me opened this issue 4 years ago • 3 comments

环境

  • python 3.6.6
  • win7
  • uiautomation~=2.0.9
  • 打开QQ登陆框

定位打印的元素

2020-12-27 12:41:41.194 automation.py[75] main -> Starts, Current Cursor Position: (621, 433)
ControlType: PaneControl    ClassName: #32769    AutomationId:     Rect: (0,0,1366,768)[1366x768]    Name: 桌面    Handle: 0x10010(65552)    Depth: 0    SupportedPattern: LegacyIAccessiblePattern
    ControlType: WindowControl    ClassName: TXGuiFoundation    AutomationId:     Rect: (435,149,930,619)[495x470]    Name: QQ    Handle: 0x1204F2(1180914)    Depth: 1    SupportedPattern: LegacyIAccessiblePattern
        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (0,0,0,0)[0x0]    Name:     Handle: 0x0(0)    Depth: 2    SupportedPattern: LegacyIAccessiblePattern
        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (440,154,925,614)[485x460]    Name:     Handle: 0x0(0)    Depth: 2    SupportedPattern: LegacyIAccessiblePattern
            ControlType: PaneControl    ClassName:     AutomationId:     Rect: (440,212,925,615)[485x403]    Name:     Handle: 0x0(0)    Depth: 3    SupportedPattern: LegacyIAccessiblePattern
                ControlType: PaneControl    ClassName:     AutomationId:     Rect: (464,214,900,552)[436x338]    Name:     Handle: 0x0(0)    Depth: 4    SupportedPattern: LegacyIAccessiblePattern
                    ControlType: PaneControl    ClassName:     AutomationId:     Rect: (467,218,897,548)[430x330]    Name:     Handle: 0x0(0)    Depth: 5    SupportedPattern: LegacyIAccessiblePattern
                        ControlType: ImageControl    ClassName:     AutomationId:     Rect: (467,218,897,351)[430x133]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
                ControlType: PaneControl    ClassName:     AutomationId:     Rect: (440,212,925,615)[485x403]    Name:     Handle: 0x0(0)    Depth: 4    SupportedPattern: LegacyIAccessiblePattern
                    ControlType: PaneControl    ClassName:     AutomationId:     Rect: (461,212,903,554)[442x342]    Name:     Handle: 0x0(0)    Depth: 5    SupportedPattern: LegacyIAccessiblePattern
                        ControlType: ImageControl    ClassName:     AutomationId:     Rect: (461,212,903,554)[442x342]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
                        ControlType: ImageControl    ClassName:     AutomationId:     Rect: (461,345,903,745)[442x400]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
                        ControlType: ImageControl    ClassName:     AutomationId:     Rect: (0,0,0,0)[0x0]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
                        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (461,212,903,554)[442x342]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
                            ControlType: PaneControl    ClassName:     AutomationId:     Rect: (461,212,903,554)[442x342]    Name:     Handle: 0x0(0)    Depth: 7    SupportedPattern: LegacyIAccessiblePattern
                                ControlType: PaneControl    ClassName:     AutomationId:     Rect: (461,212,903,554)[442x342]    Name:     Handle: 0x0(0)    Depth: 8    SupportedPattern: LegacyIAccessiblePattern
                                    ControlType: PaneControl    ClassName:     AutomationId:     Rect: (466,279,903,549)[437x270]    Name:     Handle: 0x0(0)    Depth: 9    SupportedPattern: LegacyIAccessiblePattern
                                        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (466,279,903,354)[437x75]    Name:     Handle: 0x0(0)    Depth: 10    SupportedPattern: LegacyIAccessiblePattern
                                        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (466,385,896,514)[430x129]    Name:     Handle: 0x0(0)    Depth: 10    SupportedPattern: LegacyIAccessiblePattern
                                            ControlType: PaneControl    ClassName:     AutomationId:     Rect: (557,385,812,455)[255x70]    Name:     Handle: 0x0(0)    Depth: 11    SupportedPattern: LegacyIAccessiblePattern
                                                ControlType: PaneControl    ClassName:     AutomationId:     Rect: (557,387,812,415)[255x28]    Name:     Handle: 0x0(0)    Depth: 12    SupportedPattern: LegacyIAccessiblePattern
                                                    ControlType: ComboBoxControl    ClassName:     AutomationId:     Rect: (557,387,812,411)[255x24]    Name: QQ号码    Handle: 0x0(0)    Depth: 13    ValuePattern.Value: 284772894    SupportedPattern: LegacyIAccessiblePattern ValuePattern
                                                        ControlType: EditControl    ClassName:     AutomationId:     Rect: (586,388,783,411)[197x23]    Name:     Handle: 0x0(0)    Depth: 14    ValuePattern.Value: 284772894    SupportedPattern: LegacyIAccessiblePattern ValuePattern
                                                    ControlType: ImageControl    ClassName:     AutomationId:     Rect: (566,392,578,408)[12x16]    Name:     Handle: 0x0(0)    Depth: 13    SupportedPattern: LegacyIAccessiblePattern
                                                ControlType: PaneControl    ClassName:     AutomationId:     Rect: (566,416,802,453)[236x37]    Name:     Handle: 0x0(0)    Depth: 12    SupportedPattern: LegacyIAccessiblePattern
                                                    ControlType: PaneControl    ClassName:     AutomationId:     Rect: (566,427,802,452)[236x25]    Name: 密码    Handle: 0x0(0)    Depth: 13    SupportedPattern: LegacyIAccessiblePattern
                                                        ControlType: PaneControl    ClassName:     AutomationId:     Rect: (580,428,802,452)[222x24]    
...
 ControlType: PaneControl    ClassName:     AutomationId:     Rect: (560,491,902,536)[342x45]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern
     ControlType: ButtonControl    ClassName:     AutomationId:     Rect: (862,513,884,535)[22x22]    Name:     Handle: 0x0(0)    Depth: 7    SupportedPattern: InvokePattern LegacyIAccessiblePattern
     ControlType: ButtonControl    ClassName:     AutomationId:     Rect: (562,490,805,531)[243x41]    Name: 安全登录    Handle: 0x0(0)    Depth: 7    SupportedPattern: InvokePattern LegacyIAccessiblePattern
 ControlType: ImageControl    ClassName:     AutomationId:     Rect: (473,226,547,268)[74x42]    Name:     Handle: 0x0(0)    Depth: 6    SupportedPattern: LegacyIAccessiblePattern

测试代码

   subprocess.Popen(...)
    cas = uiautomation.PaneControl(searchDepth=13,  Name='密码')
    # cas = uiautomation.ButtonControl(searchDepth=7,  Name='安全登陆')
    cas.Click()

报错

Find Control Timeout: {Name: '安全登陆', ControlType: ButtonControl}

Louis-me avatar Dec 27 '20 04:12 Louis-me

QQ钉钉一类的软件都有一个透明的遮罩层,不过也是可以解决的

smzhao avatar Aug 12 '21 01:08 smzhao

请问楼主问题解决了吗 是如何解决的

zerolfq avatar Aug 18 '21 02:08 zerolfq

请问楼主问题解决了吗 是如何解决的

获取元素的时候定位鼠标最小元素

smzhao avatar Aug 24 '21 06:08 smzhao