首先安装pip install uiautomation, 再运行本文代码。或者下载https://github.com/yinkaisheng/Python-UIAutomation-for-Windows代码(包含了uiautomation module),直接运行demos目录里的脚本get_qq_group_members.py

首先打开qq群聊天窗口,运行automation.py -a,然后3秒内移动鼠标到qq群上其中一个成员上面(下图右下角红框中),等待打印qq群窗口信息,

可以看到qq群窗口的控件树形结构。

再根据控件结构获取信息,只需60几行代码,如下:

#!python3

# -*- coding: utf-8 -*-

"""

本脚本可以获取QQ2017(v8.9.4)群所有成员详细资料,请根据提示做对应的操作

作者:yinkaisheng@foxmail.com

"""

import time

import uiautomation as automation

def GetPersonDetail():

detailWindow = automation.WindowControl(searchDepth= 1, ClassName = 'TXGuiFoundation', SubName = '的资料')

details = ''

for control, depth in automation.WalkControl(detailWindow):

if isinstance(control, automation.EditControl):

details += control.Name + control.CurrentValue() + '\n'

details += '\n' * 2

detailWindow.Click(-10, 10)

return details

def main():

automation.Logger.WriteLine('请把鼠标放在QQ群聊天窗口中的一个成员上面,3秒后获取\n')

time.sleep(3)

listItem = automation.ControlFromCursor()

if listItem.ControlType != automation.ControlType.ListItemControl:

automation.Logger.WriteLine('没有放在群成员上面,程序退出!')

return

consoleWindow = automation.GetConsoleWindow()

if consoleWindow:

consoleWindow.SetActive()

qqWindow = listItem.GetTopWindow()

list = listItem.GetParentControl()

allListItems = list.GetChildren()

for listItem in allListItems:

automation.Logger.WriteLine(listItem.Name)

answer = input('是否获取详细信息?按y和Enter继续\n')

if answer.lower() == 'y':

automation.Logger.WriteLine('\n3秒后开始获取QQ群成员详细资料,您可以一直按住F10键暂停脚本')

time.sleep(3)

qqWindow.SetActive()

#确保群里第一个成员可见在最上面

left, top, right, bottom = list.BoundingRectangle

while allListItems[0].BoundingRectangle[1] < top:

automation.Win32API.MouseClick(right - 5, top + 20)

for listItem in allListItems:

if listItem.ControlType == automation.ControlType.ListItemControl:

if automation.Win32API.IsKeyPressed(automation.Keys.VK_F10):

if consoleWindow:

consoleWindow.SetActive()

input('\n您暂停了脚本,按Enter继续\n')

qqWindow.SetActive()

listItem.RightClick()

menu = automation.MenuControl(searchDepth= 1, ClassName = 'TXGuiFoundation')

menuItems = menu.GetChildren()

for menuItem in menuItems:

if menuItem.Name == '查看资料':

menuItem.Click()

break

automation.Logger.WriteLine(listItem.Name, automation.ConsoleColor.Green)

automation.Logger.WriteLine(GetPersonDetail())

listItem.Click()

automation.SendKeys('{Down}')

if __name__ == '__main__':

main()

input('press Enter to exit')

效果图

获取的到QQ群成员详细保存在脚本同一目录@AutomationLog.txt里

代码下载

python uiautomation_使用python UIAutomation从QQ2017(v8.9)群界面获取所有群成员详细资料,...相关推荐

  1. python uiautomation选择list内容_使用python UIAutomation从QQ2017(v8.9)群界面获取所有群成员详细资料,...

    首先安装pip install uiautomation, 再运行本文代码.或者下载https://github.com/yinkaisheng/Python-UIAutomation-for-Win ...

  2. python uiautomation 控件序号_使用python UIAutomation从QQ2016(8.0)群界面获取所有群成员详细资料,...

    automation.py是我写的一个python封装微软UIAutomation API的一个module,使用非常简单 运行automation.py -h查看帮助 首先打开qq群聊天窗口,运行a ...

  3. 【python】UI自动化-uiautomation

    UI自动化-uiautomation 0- 前言 1- inspect 2- uiautomation 3- [实战]RustDesk软件自动 安装.指定服务器信息 4- 参考文章 0- 前言 做应用 ...

  4. Python uiautomation使用---自动获取QQ群聊天记录

    使用uiautomation获取qq群聊天记录,后续可以拓展到消息自动回复.本章只简单介绍自动获取聊天记录,代码如下: import uiautomation as auto from time im ...

  5. 简单的python抢红包脚本-Python自动抢红包,超详细教程,再也不会错过微信红包了!...

    来源:python专栏 github:https://github.com/MiracleYoung/You-are-Pythonista/tree/master/PythonExercise/Too ...

  6. python项目实例代码-python开源项目及示例代码

    下面列出的各种 Python 库/模块/工具,如果名称带超链接,说明是第三方的:否则是 Python 语言内置的. 1 算法 1.1 字符串处理 re 正则表达式的标准库. StringIO / cS ...

  7. Appium+python自动化8-Appium Python API

    Appium+python自动化8-Appium Python API 前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家. 1.contexts contex ...

  8. python 内置浏览器robobrowser_【自动化测试】无需图形界面环境下的浏览器开源项目...

    Awesomium 基于Chromium无图形界面浏览器引擎. C++, .NET benv Benv是node.js开发的无界面浏览器测试环境,用于测试客户端代码. JavaScript brows ...

  9. 简单的python抢红包脚本-Python自动抢红包教程详解

    0 引言 提到抢红包,就不得不提Xposed框架,它简直是个抢红包的神器,但使用Xposed框架有一个前提条件:手机需要root,对于苹果手机的话就需要越狱了.现在的手机想要root或越狱并不容易,同 ...

最新文章

  1. java 反射加实例化内部类
  2. C#获取数据库表信息,列信息
  3. NeurIPS 2021 | 简单且通用的多视图对比图聚类方法
  4. Boost:bimap便利性标题的测试程序
  5. os.system如何传参
  6. ElasticSearch-5.3.1集群环境搭建,安装ElasticSearch-head插件,安装错误解决
  7. 无法通过ip地址连接其它电脑的数据库,但是又可以ping通,错的不是配置,而是差了一个步骤
  8. canvas.toDataURL()报错
  9. windows下安装Perl模块
  10. 168.Excel Sheet Column Title
  11. 微信扫码访问网站调用默认浏览器打开如何实现?
  12. Linux电源管理-Linux Regulator Framework代码分析
  13. JavaWeb网上购物系统项目源码+论文
  14. 【sketchup 2021】草图大师软件安装和基本使用说明【工作环境工具添加设置、视口控制界 面放大缩小平移、选择工具、在线资源导入、人物误删了怎么恢复、网上下载模型导入到sketchup中流程】
  15. python3 urlencode_Python3 parse.urlencode() 与parse.unquote()
  16. wp8 android,WP8桌面主题|WP8桌面v1.5.2 for Android版 - 玩客网
  17. Python将二维数组/多维数组转换为一维
  18. Ubuntu18.04 MOOS-ivp 编译运行
  19. 蜕变的过程总是痛苦的
  20. postcss-pxtorem使用方式

热门文章

  1. python 初步学习
  2. 适应关键业务环境的加湿系统
  3. MySQL事务(脏读、不可重复读、幻读)
  4. eclipse图标含义
  5. [转]jQuery ListBox Plugin(ListBox插件)
  6. 携程Apollo(阿波罗)配置中心在Spring Boot项目快速集成
  7. 数据库的相关语句(where,order by)
  8. C# 线程手册 第四章 线程设计原则 对等线程模型
  9. Linux之find xargs
  10. Spring Boot2.0 整合mybatis、分页插件、druid