search_key_mac.py 677 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/2/20
  4. import time
  5. import atomac
  6. class SearchKey:
  7. @classmethod
  8. def start_wechat(cls):
  9. # 启动应用并获取应用信息
  10. bundle_id = "com.tencent.xinWeChat"
  11. atomac.launchAppByBundleId(bundle_id)
  12. automator = atomac.getAppRefByBundleId(bundle_id)
  13. time.sleep(3)
  14. # 获取当前应用window
  15. window = automator.windows()[0]
  16. print(f"当前应用window:{window}")
  17. msg_box = window.findFirstR(AXRole="AXCell", AXIdentifier="MMChatsTableCellView_0")
  18. print(msg_box.getAttributes())
  19. if __name__ == "__main__":
  20. SearchKey.start_wechat()