1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- # -*- coding: utf-8 -*-
- # @Author: wangkun
- # @Time: 2023/2/20
- import time
- import atomac
- class SearchKey:
- @classmethod
- def start_wechat(cls):
- # 启动应用并获取应用信息
- bundle_id = "com.tencent.xinWeChat"
- print("启动微信")
- atomac.launchAppByBundleId(bundle_id)
- automator = atomac.getAppRefByBundleId(bundle_id)
- time.sleep(1)
- # 获取当前应用window
- window = automator.windows()[0]
- print(f"当前应用window:{window.AXTitle}")
- # 查找聊天按钮
- print("查找聊天按钮")
- chat_btn = window.findFirstR(AXHelp="微信", AXRole="AXRadioButton")
- # print(chat_btn.getAttributes())
- # 点击聊天按钮,展开聊天列表
- print("点击聊天按钮")
- chat_btn.Press()
- time.sleep(1)
- # # 查找文件传输助手
- # print("查找文件传输助手")
- # chat_help = window.findFirstR(AXRole="AXCell")
- # print(f"文件传输助手:{chat_help}")
- # print("点击文件传输助手")
- # chat_help_position = chat_help.AXSize
- # chat_help.clickMouseButtonLeft(chat_help_position)
- print("查找微信指数小程序消息")
- weixinzhishu = window.findFirstR(AXValue="微信指数", AXRole="AXStaticText")
- print(f"微信指数小程序消息:{weixinzhishu}")
- print("点击微信指数小程序消息")
- weixinzhishu_position = weixinzhishu.AXSize
- print(weixinzhishu_position)
- # weixinzhishu.clickMouseButtonLeft(weixinzhishu_position)
- # chat_msg.clickMouseButtonLeft((780, 450))
- # chat_msg_position.Press()
- time.sleep(3)
- if __name__ == "__main__":
- SearchKey.start_wechat()
|