1. 启动 APP   【所有的使用示例必须放到 script_main(self) 类函数下使用】           功能视频教程: https://www.bilibili.com/video/BV14w4m127iK/

    def start_app(self, name: str, wait_time: float = 5, interval_time: float = 0.5) -》 bool:
        """
            启动 APP
            Start APP

            name: APP名字或者包名
            wait_time: 等待时间,默认取 5秒
            interval_time: 轮询间隔时间,默认取 0.5秒
            return:成功返回True 失败返回False

            name: APP name or package name
            wait_time: waiting time, which is 5 seconds by default
            interval_time: the polling interval, which is 0.5 seconds by default
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.start_app("微信", 5, 0.5)
    print(result) 

    

2. 判断app是否正在运行          功能视频教程: https://www.bilibili.com/video/BV1JH4y1A7m8/

    def app_is_running(self, app_name: str) -》 bool:
        """
            判断app是否正在运行(无障碍权限开启只判断前台,未开启则包含前后台 是否正在运行)
            Judge whether the app is running 
            (if the barrier-free permission is enabled, only judge whether the foreground is running; if it is not enabled, 
            it includes whether the foreground and background are running)

            return: 成功返回True 失败返回False
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.app_is_running("微信")
    print(result) 

    

3. 获取已安装app包名          功能视频教程: https://www.bilibili.com/video/BV1Qr421g7Ko/

    def get_installed_packages(self) -》 list:
        """
            获取已安装app的包名(不包含系统APP)
            Gets the package name of the installed APP (excluding the system app)

            return: 包名列表 或者 空[]
            return: The package name list is either empty []
        """

    # 使用示例 [Demo]
    result = self.get_installed_packages()
    print(result) 

    

4. 获取设备IP地址          功能视频教程: https://www.bilibili.com/video/BV1Zb421a7eL/

    def get_device_ip(self) -》 str:
        """
            获取设备IP地址
            Get the device IP address

            return: 设备IP地址字符串
            return: device IP address string
        """

    # 使用示例 [Demo]
    result = self.get_device_ip()
    print(result) 

    

5. 获取 Android 设备 ID          功能视频教程: https://www.bilibili.com/video/BV1Xm411y71j/

    def get_android_id(self) -》 str:
        """
            获取 Android 设备 ID
            Get AndroID device id

            return: Android 设备 ID 字符串
            return: AndroID device id string
        """

    # 使用示例 [Demo]
    result = self.get_android_id()
    print(result) 

    

6. 获取屏幕大小          功能视频教程: https://www.bilibili.com/video/BV1Bp421Q7Hi/

    def get_window_size(self) -》 dict:
        """
            获取屏幕大小
            Get the screen size

            return: 屏幕大小, 字典格式
            return: screen size, dictionary format
        """

    # 使用示例 [Demo]
    result = self.get_window_size()
    print(result)

    

7. 获取图片大小          功能视频教程: https://www.bilibili.com/video/BV1861TYZEMa/

    def get_image_size(self, image_path) -》 dict:
        """
            获取图片大小
            Get the picture size

            image_path: 图片路径,安卓文件根目录: /storage/emulated/0/
            return: 图片大小, 字典格式, 失败返回 {'width': -1.0, 'height': -1.0}

            image_path: image path Android file root directory: /storage/emulated/0/
            return: picture size, dictionary format
        """

    # 使用示例 [Demo]
    result = self.get_image_size("1.png")  # 读取根目录中1.png图片大小
    print(result)

    

8. Toast 弹窗          功能视频教程: https://www.bilibili.com/video/BV1Vt421A7At/

    def show_toast(self, text: str, duration: float = 3) -》 bool:
        """
            Toast 弹窗
            Toast popup window

            text: 弹窗内容
            duration: 弹窗持续时间默认3秒
            return: 成功返回True 失败返回False

            text: pop-up contents
            duration: The default duration of pop-up window is 3 seconds
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.show_toast("我是一个弹窗", 3)
    print(result)

    

9. 发送文本          功能视频教程: https://www.bilibili.com/video/BV1GZ421H7jw/

    def send_keys(self, text: str) -》 bool:
        """
            发送文本,需要打开 AiBot 输入法
            To send text, you need to open the AiBot input method

            text: 文本内容
            return:  成功返回True 失败返回False

            text: text content
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.send_keys("我是一个文本")
    print(result)

    

10. 发送VK虚拟键          功能视频教程: https://www.bilibili.com/video/BV1Qb421a79T/

    def send_vk(self, vk: int) -》 bool:
        """
            发送VK虚拟键
            Send vk

            vk: 虚拟键值
            return: 成功返回True 失败返回False

            虚拟键值按键对照表 https://blog.csdn.net/yaoyaozaiye/article/details/122826340
        """

    # 使用示例 [Demo]
    result = self.send_vk(18)
    print(result)

    

11. 返回          功能视频教程: https://www.bilibili.com/video/BV1UJ4m1J7dF/

    def back(self) -》 bool:
        """
            返回
            return

            return: 成功返回True 失败返回False
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.back()
    print(result)
    
    

12. 返回桌面          功能视频教程: https://www.bilibili.com/video/BV1Qi421275n/

    def home(self) -》 bool:
        """
            返回桌面
            Back to the desktop

            return: 成功返回True 失败返回False
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.home()
    print(result)

    

13. 显示最近任务          功能视频教程: https://www.bilibili.com/video/BV1KH4y1P7Be/

    def recent_tasks(self) -》 bool:
        """
            显示最近任务
            Show recent tasks

            return: 成功返回True 失败返回False
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.recent_tasks()
    print(result)

    

14. 打开 开/关机 对话框          功能视频教程: https://www.bilibili.com/video/BV1pWm5Y6Eyp/

    def power_dialog(self) -》 bool:
        """
            打开 开/关机 对话框,基于无障碍权限
            Open the on/off dialog box, based on accessibility rights

            return:成功返回True 失败返回False
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.power_dialog()
    print(result)

    

15. 拨打电话          功能视频教程: https://www.bilibili.com/video/BV1WWm5Y6EL9/

    def call_phone(self, mobile: str) -》 bool:
        """
            拨打电话
            dial

            mobile: 手机号码
            return: 成功返回True 失败返回False

            mobile: mobile phone number
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.call_phone("13145678987")
    print(result)

    

16. 发送短信          功能视频教程: https://www.bilibili.com/video/BV1WWm5Y6E5s/

    def send_msg(self, mobile, text) -》 bool:
        """
            发送短信
            send a text message

            mobile: 手机号码
            text: 短信内容
            return: 成功返回True 失败返回False

            mobile: mobile phone number
            text: short message content
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.send_msg("13145678987", "我是一条短信内容")
    print(result)

    

17. 获取活动页          功能视频教程: https://v.douyin.com/iBEekmwW/

    def get_activity(self) -》 str:
        """
            获取活动页
            Get active page

            return: 当前的窗口UI名称
            return: the current UI name of the window
        """

    # 使用示例 [Demo]
    result = self.get_activity()
    print(result)

    

18. 获取当前活动app包名          功能视频教程: https://www.bilibili.com/video/BV1N82ZYaEJn/

    def get_package(self) -》 str:
        """
            获取当前活动app包名
            Get package name

            return: 包名称:"com.aibot.client"
            return: package name: "com.aibot.client"
        """

    # 使用示例 [Demo]
    result = self.get_package()
    print(result)

    

19. 设置剪切板文本          功能视频教程: https://www.bilibili.com/video/BV1182ZYhEsR/

    def set_clipboard_text(self, text: str) -》 bool:
        """
            设置剪切板文本
            Set clipboard text

            text: 文本
            return: 成功返回True 失败返回False

            text: text
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.set_clipboard_text("我是一条内容")
    print(result)

    

20. 获取剪切板内容          功能视频教程: https://www.bilibili.com/video/BV1K82ZYaEAW/

    def get_clipboard_text(self) -》 str:
        """
            获取剪切板内容(需要开启Aibote输入法)
            Get the clipboard content

            return: 剪切板内容
            return: Clipboard content
        """

    # 使用示例 [Demo]
    result = self.get_clipboard_text()
    print(result)

    

21. 跳转URL          功能视频教程: https://www.bilibili.com/video/BV1D61TYZEJ9/

    def start_activity(self, action: str, uri: str = "", package_name: str = "", class_name: str = "", typ: str = "") -》 bool:
        """
            跳转 URL, 在Aibote界面或者开启悬浮窗才有效
            Intent jump
            
            参考文章:http://segmentfault.com/a/1190000000646719
            references:http://segmentfault.com/a/1190000000646719

            action: 动作,例如 "android.settings.APPLICATION_DETAILS_SETTINGS"
            uri: 跳转链接,例如:打开支付宝扫一扫界面,"alipayqr://platformapi/startapp?saId=10000007"
            package_name: 包名,"com.xxx.xxxxx"
            class_name: 类名
            typ: 类型
            return: True或者 False

            action: Action, such as "android.settings.APPLICATION_DETAILS_SETTINGS"
            uri: jump link, for example: open Alipay scan interface, "AlipayQR://PlatformAPI/startapp? saId=10000007"
            package_name: package name, "com.xxx.xxxxx"
            class_name: class name
            typ: type
            return: True or False
        """

    # 跳转应用详情页 使用示例 [Demo]
    result = self.get_installed_packages()    # 获取app所有包名
    print(result)

    result = self.start_activity("android.settings.APPLICATION_DETAILS_SETTINGS", "package:com.tencent.tmgp.sgame", "", "", "")
    print(result)


    # 跳转网页 使用示例 [Demo]
    result = self.start_activity("android.intent.action.VIEW", "https://www.baidu.com", "", "")
    print(result)



    

22. 写入安卓文件          功能视频教程: https://www.bilibili.com/video/BV1wgmKY7EUn/

    def write_android_file(self, remote_path: str, text: str, append: bool = False) -》 bool:
        """
            写入安卓文件 
            Write to Android file

            remote_path: 安卓文件默认根目录:/storage/emulated/0/,  文件名必须是.txt后缀结
            text: 写入的内容
            append: 可选参数,是否追加,默认覆盖文件内容
            return: True 或者 False

            remote_path: Android file path /storage/emulated/0/: Android file root directory
            text: the text content to be written
            append: Whether to append the pattern
            return: True or False
        """

    # 使用示例 [Demo]
    result = self.write_android_file("1.txt", "我是一个写入txt的内容", False)
    print(result)

    

23. 读取安卓文件          功能视频教程: https://www.bilibili.com/video/BV1AgmKY7EKG/

    def read_android_file(self, remote_path: str) -》 str:
        """
            读取安卓文件 
            Read Android file

            remote_path: 安卓文件默认根目录: /storage/emulated/0/
            return: 文件内容

            remote_path: Android file path /storage/emulated/0/: Android file root directory
            return: file content
        """

    # 使用示例 [Demo]
    result = self.read_android_file("1.txt")
    print(result)

    

24. 安卓文件是否存在          功能视频教程: https://www.bilibili.com/video/BV1wgmKY7E8b/

    def exists_android_file(self, remote_path: str) -》 bool:
        """
            安卓文件是否存在
            Does the Android file exist

            remote_path: 安卓文件默认根目录: /storage/emulated/0/
            return: 存在返回True 不存在返回False

            Remote_path: Android file path
            Return: existence returns True; non-existence returns False
        """

    # 使用示例 [Demo]
    result = self.exists_android_file("1.txt")
    print(result)

    

25. 获取文件夹内的所有文件          功能视频教程: https://www.bilibili.com/video/BV1rbyTYGEvg/

    def get_android_sub_files(self, android_directory: str = "") -》 list:
        """
            获取文件夹内的所有文件(不包含深层子目录)
            Get all files in the folder (excluding deep subdirectories)

            android_directory: 安卓目录,默认为根目录下所有文件名, 安卓文件默认根目录: /storage/emulated/0/
            return: 文件名列表

            android_directory: Android directory, which defaults to all file names in the root directory
            return: list of file names
        """

    # 使用示例 [Demo]
    result = self.get_android_sub_files()   # 默认获取根目录文件
    print(result)

    

26. 创建安卓文件夹          功能视频教程: https://www.bilibili.com/video/BV1wbyTYVE6k/

    def make_android_dir(self, android_directory: str) -》 bool:
        """
            创建安卓文件夹
            Create Android folder

            android_directory: 安卓文件默认根目录: /storage/emulated/0/
            return: 成功返回True 失败返回False

            android_directory: Android directory  /storage/emulated/0/: Android file root directory
            return: existence returns True; non-existence returns False
        """

    # 使用示例 [Demo]
    result = self.make_android_dir("PyAibote")   # 在根目录创建一个PyAibote文件夹
    print(result)

    

27. 删除安卓文件          功能视频教程: https://www.bilibili.com/video/BV1C4yTYCELC/

    def delete_android_file(self, remote_path: str) -》 bool:
        """
            删除安卓文件
            Delete Android files

            remote_path: 安卓文件默认根目录: /storage/emulated/0/
            return: 成功返回True 失败返回False

            remote_path: Android file path.
            return: Returns True successfully, and returns False if it fails
        """

    # 使用示例 [Demo]
    result = self.delete_android_file("1.txt")   # 在根目录删除1.txt文件
    print(result)

    

28. 关闭连接          功能视频教程: https://www.bilibili.com/video/BV1BFCUYJEqF/

    def close_driver(self):
        """
            关闭连接
            Close the connection
        """

    # 使用示例 [Demo]
    result = self.close_driver() 
    print(result)

29. 不同分辨率坐标转换算法          功能视频教程: https://www.bilibili.com/video/BV1oPCUY2ExQ/


    def coordinate_transform(self, coordinate: tuple, resolution_a: tuple, resolution_b: tuple) -》 tuple:
        """
            根据屏幕分辨率缩放比例,进行不同分辨率坐标转换
            According to the screen resolution scaling, coordinate conversion with different resolutions is carried out.

            coordinate: 需要装换的坐标可以是x,y坐标,也可以是矩形坐标 x1, y1, x2, y2
            resolution_a: 你抓取过坐标的设备标准分辨率
            resolution_b:你需要转换的设备分辨率
            return: 元祖

            coordinate: the coordinates to be replaced can be x,y coordinates or rectangular coordinates x1, y1, x2, y2
            resolution_a: The standard resolution of the device for which you have grabbed the coordinates
            resolution_b: The device resolution you need to convert
            return: Yuanzu
        """

    # 使用示例 [Demo]
    result = self.coordinate_transform(((291, 2115)),(1080,2400),(1080, 1920))  # 转换x,y坐标
    print(result) 


    result = self.coordinate_transform(((291, 2115, 540, 2227)),(1080,2400),(1080, 1920))  # 转换矩形坐标
    print(result) 


30. 设置安卓客户端接收超时          功能视频教程: https://www.bilibili.com/video/BV1iPCUY2EeT/

    def set_android_timeout(self, timeout: float = 60):
        """
            设置安卓客户端接收超时,默认为永久等待
            Set the receiving timeout of Android client, and the default is permanent waiting

            timeout: 超时时间,单位秒
            return: 总是True

            timeout: timeout in milliseconds
            return: always True
        """

    # 使用示例 [Demo]
    result = self.set_android_timeout(60) 
    print(result)