First to https://github.com/yinkaisheng/Python-UIAutomation-for-Windows download automation.py and AutomationClient.dll
automation.py is a module of a Python encapsulated Microsoft UIAutomation API that is very simple to use
Run Automation.py-h View Help
First open the QQ Group Chat window, run Automation.py-a, and then 3 seconds to move the mouse to the QQ group on one of the members above (the lower right corner of the red box), waiting to print QQ Group window information,
You can see the control tree structure of the QQ group window.
To get information based on the structure of the control, just 60 lines of code, as follows:
1 #!python32 #-*-coding:utf-8-*-3 " "4 This script can get all the member details of QQ2016 Group, please do the corresponding action according to the prompt5 [email protected]6 2016-01-067 " "8 Import Time9 ImportAutomationTen One A defgetpersondetail (): -Detailwindow = Automation. Windowcontrol (searchdepth= 1, ClassName ='txguifoundation', SubName ='of Information') -Detailpane = Automation. Panecontrol (searchfromcontrol= detailwindow, Name ='Information') theDetails ="' - forControl, depthinchAutomation. Walktree (Detailpane,LambdaC:c.getchildren ()): - ifControl. ControlType = =Automation. Controltype.textcontrol: -Details + =control. Name + elifControl. ControlType = =Automation. Controltype.editcontrol: -Details + = control. CurrentValue () +'\ n' +Details + ='\ n'* 2 ADetailwindow.click (0.95, 0.02) at returnDetails - - defMain (): - Print('please put the mouse in the QQ Group Chat window of a member above, 3 seconds to get \ n') -Time.sleep (3) -ListItem =Automation. Controlfromcursor () in ifListitem.controltype! =Automation. Controltype.listitemcontrol: - Print('does not put on the group member above, the program exits! ') to return +Consolewindow =Automation. Getconsolewindow () - consolewindow.setactive () theQqwindow =Listitem.gettopwindow () *List =Listitem.getparentcontrol () $Alllistitems =list. GetChildren ()Panax Notoginseng forListIteminchAlllistitems: - Automation. Logger.writeline (Listitem.name) theAnswer = input ('do you want to get more information? Press Y and enter to continue \ n') + ifAnswer.lower () = ='y': A Print('\n3 seconds after the start to get QQ group member details, you can always hold down the F10 key to pause the script') theTime.sleep (3) + qqwindow.setactive () -Time.sleep (0.5) $ #Make sure the first member of the group is visible at the top. $Left, top, right, bottom =list. Boundingrectangle - whileAlllistitems[0]. BOUNDINGRECTANGLE[1] <Top: -Automation. Win32api.mouseclick (right-5, top + 20) theTime.sleep (0.5) - forListIteminchAlllistitems:Wuyi ifListitem.controltype = =Automation. Controltype.listitemcontrol: the ifAutomation. win32api.iskeypressed (automation. KEYS.VK_F10): - consolewindow.setactive () WuInput'\ nyou Paused the script, press ENTER to continue \ n') - qqwindow.setactive () AboutTime.sleep (0.5) $ Listitem.click () -Time.sleep (0.5) - Listitem.rightclick () -menu = Automation. Menucontrol (searchdepth= 1, ClassName ='txguifoundation') AMenuItems =menu. GetChildren () + forMenuIteminchMenuItems: the ifMenuitem.name = ='View Material': - MenuItem.Click () $ Break the Automation. Logger.writeline (Listitem.name, automation. Consolecolor.green) the Automation. Logger.writeline (Getpersondetail ()) the Listitem.click () theTime.sleep (0.5) -Automation. Win32api.sendkeys ('{down}') in the the if __name__=='__main__': About Main () theInput'Press Enter to exit')
Get to QQ group members in detail saved in script same directory @automationlog.txt
Code Download Https://github.com/yinkaisheng/Python-UIAutomation-for-Windows
Use Python uiautomation to get all the group member details from the QQ2016 (8.0) group interface,