Beispiel #1
0
    def am_list(serial, is_system=False):
        """获得应用列表"""

        if not is_system:
            _boo = False
            desc_type = "用户应用"
            desc = "获取 {0} 信息成功!\n已复制到剪贴板,请粘贴后使用"
            msg_desc = "正在获取用户安装的应用列表信息"
        else:
            _boo = True
            desc_type = "全部应用"
            desc = "获取 {0} 信息成功!\n已复制到剪贴板,请粘贴后使用"
            msg_desc = "正在获取全部的应用列表信息"
        util_atool.show_msg(msg_desc)

        # 执行命令行
        s = util_atool.pm_list_f(serial, _boo)
        # 复制到剪贴板
        desc_add = '以下是{desc}信息,如需 拷贝 apk 到本机可使用:\n\t{adb} -s {serial} pull "[/data/app/xx.apk]"\n\n'
        desc_add = desc_add.format(desc=desc_type,
                                   adb=util_atool.adb_path,
                                   serial=serial)
        s = desc_add + s
        utils.clipboard_set(s)

        # 提示
        desc = desc.format(desc_type)
        utils.showinfo(desc)
Beispiel #2
0
    def search_routers(self):
        print("正在扫描..., 请稍等...")

        # 获取本地ip地址列表
        local_ips = socket.gethostbyname_ex(socket.gethostname())[2]
        # print("{}本地ip".format(local_ips))
        # 存放线程列表池
        all_threads = []
        # 循环本地网卡IP列表
        for ip in local_ips:
            for i in range(1, 255):
                # 把网卡IP"."进行分割,生成每一个可用地址的列表
                array = ip.split('.')
                # 获取分割后的第四位数字,生成该网段所有可用IP地址
                array[3] = str(i)
                # 把分割后的每一可用地址列表,用"."连接起来,生成新的ip
                new_ip = '.'.join(array)
                # print(new_ip)
                # 遍历需要扫描的端口号列表
                for port in self.port_list:
                    dst_port = int(port)
                    # 循环创建线程去链接该地址
                    t = threading.Thread(target=self.check_ip, args=(new_ip, dst_port))
                    t.start()
                    # 把新建的线程放到线程池
                    all_threads.append(t)
        # 循环阻塞主线程,等待每一字子线程执行完,程序再退出
        for t in all_threads:
            t.join()
        util_atool.show_msg(self.search_result)
Beispiel #3
0
 def send_input(serial):
     """发送文本"""
     s = utils.clipboard_get()
     if s:
         util_atool.send_input(serial, s)
         util_atool.show_msg('正发送文本 {0} 到 {1} 设备上'.format(s, serial))
     else:
         utils.showinfo("请先复制字符到剪贴板(仅英文字母和数字)")
Beispiel #4
0
 def install_by_clipboard(self, _serial):
     """安卓 自动获取剪贴板中的地址"""
     p = utils.clipboard_get()
     p = p.replace("\r", "")
     arr = p.split("\n")
     if os.path.exists(arr[0]):
         f = arr[0]
         util_atool.show_msg('从剪贴板中安装apk\n{}'.format(f))
         self.install_handle(_serial, f)
     else:
         util_atool.show_msg("剪贴板里没有apk:{}".format(utils.clipboard_get()))
Beispiel #5
0
    def install_handle(self, serial, apk_file):
        """安装 apk"""
        if apk_file:
            self.last_apk = apk_file
            self.show_install(apk_file)
            util_atool.show_msg("安装 {0} 到 {1}".format(apk_file, serial))

            # 执行操作
            self.t1 = threading.Thread(target=self.install_apk,
                                       args=(serial, apk_file))
            self.t1.setDaemon(True)
            self.t1.start()
Beispiel #6
0
 def send_input_clipper(serial, is_get=False):
     """发送文本"""
     if not is_get:
         s = utils.clipboard_get()
         if s:
             util_atool.send_input_clipper_set(serial, s)
             util_atool.show_msg('正发送文本 {0} 到 {1} 设备上'.format(s, serial))
         else:
             utils.showinfo("请先复制字符到剪贴板")
     else:
         s = util_atool.send_input_clipper_get(serial)
         utils.clipboard_set(s)
         util_atool.show_msg("安卓设备的剪贴板发现“{0}”\n已复制到本机的剪贴板".format(s))
Beispiel #7
0
    def can_i_scrcpy(self):
        if not self.can_i_record():
            util_atool.show_msg(self.product_name + " 不支持scrcpy")
            return False

        s_name = "scrcpy.exe" if utils.is_windows else "scrcpy"
        p = Path(util_atool.adb_path).with_name(s_name)
        if p.exists():
            return True
        else:
            print("{0}  {1}".format(p, p.exists()))
            if utils.is_windows:
                s = "请先安装scrcpy。将scrcpy.exe放在 “D:\\FFmpeg”目录下"
            else:
                s = "请先安装scrcpy。brew install scrcpy"
            util_atool.show_msg(s)
            return False
Beispiel #8
0
    def btn_call(self, event):
        """[summary]

        Arguments:
            event {[type]} -- [description]
        KEYCODE_BACK    返回键  4
        KEYCODE_ENTER	回车键	66
        KEYCODE_ESCAPE	ESC键	111

        KEYCODE_DPAD_CENTER	导航键 确定键	23
        KEYCODE_DPAD_UP	导航键 向上	19
        KEYCODE_DPAD_DOWN	导航键 向下	20
        KEYCODE_DPAD_LEFT	导航键 向左	21
        KEYCODE_DPAD_RIGHT	导航键 向右	22

        KEYCODE_MOVE_HOME	光标移动到开始键	122
        KEYCODE_MOVE_END	光标移动到末尾键	123
        KEYCODE_PAGE_UP	向上翻页键	92
        KEYCODE_PAGE_DOWN	向下翻页键	93
        KEYCODE_DEL	退格键	67
        KEYCODE_FORWARD_DEL	删除键	112
        KEYCODE_INSERT	插入键	124
        KEYCODE_TAB	Tab键	61
        KEYCODE_NUM_LOCK	小键盘锁	143
        KEYCODE_CAPS_LOCK	大写锁定键	115
        KEYCODE_BREAK	Break/Pause键	121
        KEYCODE_SCROLL_LOCK	滚动锁定键	116
        KEYCODE_ZOOM_IN	放大键	168
        KEYCODE_ZOOM_OUT	缩小键	169

        KEYCODE_HOME    3
        KEYCODE_MENU    82
        KEYCODE_SETTINGS    176
        KEYCODE_SEARCH  84
        """

        key_code = 0
        if event.widget:
            t = (('btn_up', 19), ('btn_down', 20), ('btn_left', 21),
                 ('btn_right', 22), ('btn_enter', 23), ('btn_back', 4),
                 ('btn_menu', 82), ('btn_screen', -1), ('btn_vol_mute', 164),
                 ('btn_vol_up', 24), ('btn_vol_down', 25), ('btn_home', 3),
                 ('btn_power', 26), ('btn_search', 84), ('btn_switch', 187))
            try:
                widget_name = event.widget.name if hasattr(
                    event.widget, 'name') else ''
                for obj in t:
                    if obj[0] == widget_name:
                        key_code = obj[1]
                        break
            except AttributeError as e:
                # error: has not attribute
                print(e)

        if event.keycode:
            kc = event.keycode
            if kc != "??":
                util_atool.show_msg(kc)
                key_code = event.keycode

            if kc == 16:
                key_code = 82

        # 处理键盘事件
        if event.keysym:
            t = (
                'Up',
                19,
                'Down',
                20,
                'Left',
                21,
                'Right',
                22,
                'Return',
                23,
                'BackSpace',
                4,
                'Cancel',
                4,

                # 'w', 19,
                # 's', 20,
                # 'a', 21,
                # 'd', 22,
                #
                # 'z', 82,
                # 'x', -1,
                # 'c', 4,

                # "a", "KEYCODE_A",
                # "b", "KEYCODE_B",
                # "c", "KEYCODE_C",
                # "d", "KEYCODE_D",
                # "e", "KEYCODE_E",
                # "f", "KEYCODE_F",
                # "g", "KEYCODE_G",
                # "h", "KEYCODE_H",
                # "i", "KEYCODE_I",
                # "j", "KEYCODE_J",
                # "k", "KEYCODE_K",
                # "l", "KEYCODE_L",
                # "m", "KEYCODE_M",
                # "n", "KEYCODE_N",
                # "o", "KEYCODE_O",
                # "p", "KEYCODE_P",
                # "q", "KEYCODE_Q",
                # "r", "KEYCODE_R",
                # "s", "KEYCODE_S",
                # "t", "KEYCODE_T",
                # "u", "KEYCODE_U",
                # "v", "KEYCODE_V",
                # "w", "KEYCODE_W",
                # "x", "KEYCODE_X",
                # "y", "KEYCODE_Y",
                # "z", "KEYCODE_Z",

                # "0", "KEYCODE_0",
                # "1", "KEYCODE_1",
                # "2", "KEYCODE_2",
                # "3", "KEYCODE_3",
                # "4", "KEYCODE_4",
                # "5", "KEYCODE_5",
                # "6", "KEYCODE_6",
                # "7", "KEYCODE_7",
                # "8", "KEYCODE_8",
                # "9", "KEYCODE_9",
                'F5',
                82,
                'F6',
                -1,
                'F7',
                4)

            sym = event.keysym
            if sym != "??":
                util_atool.show_msg(sym)
            if t.count(sym):
                index = t.index(sym)
                if index < len(t) - 2:
                    key_code = t[index + 1]

        if key_code == -1:
            self.screen_shot()
        elif key_code:
            serial = self.serial
            utils.thread_func(util_atool.send_keyevent, (serial, key_code))
Beispiel #9
0
 def thread_emulator(self, serial, _):
     result = util_atool.connect(serial)
     util_atool.show_msg(result)
     self.show_connect_result(serial)
Beispiel #10
0
 def pull_apk(serial, package):
     util_atool.show_msg("正将{}相关的apk拷贝到本机".format(package))
     apk = util_atool.pull_apk(serial, package)
     if apk:
         s = "已保存至:\n{}\n是否前往?".format(apk)
         utils.alert(s, utils.open_file, [apk, True])