1234567891011121314151617181920212223242526272829303132333435363738 |
- # -*- coding: utf-8 -*-
- # @Author: wangkun
- # @Time: 2022/8/15
- import atomacos
- # from atomacos import keyboard
- from time import sleep
- bundle_id = "com.tencent.xinWeChat"
- # 启动应用
- atomacos.launchAppByBundleId(bundle_id)
- atomator = atomacos.getAppRefByBundleId(bundle_id)
- sleep(3)
- # 获取当前窗口
- wx = atomator.windows()[0]
- print(wx)
- # 获取输入框
- lt = wx.findFirstR(AXRole="AXRadioButton", AXHelp="微信")
- print(lt)
- # 获取位置参数
- lt_position = lt.AXPosition
- lt_size = lt.AXSize
- # 注意AXPositon得到的坐标是元素左上角的坐标,需要根据实际大小得到元素中心点坐标
- lt_click = (lt_position[0] + lt_size[0] / 2, lt_position[1] + lt_size[1])
- print(lt_click)
- lt.clickMouseButtonLeft(lt_position)
- # 输入内容(输入键盘字符,US_keyboard)
- # s1 = lt.findFirstR(AXRole='AXTextArea', AXRoleDescription='文本输入区')
- s1 = lt.findFirstR(AXRole='AXTextArea', AXLable='搜索')
- s1_p = s1.AXPosition
- s1_s = s1.AXSize
- s1.tripleClickMouse((s1_p[0] + s1_s[0] / 2, s1_p[1] + s1_s[1] / 2))
- s1.sendKeys('公众号')
|