首页 > 其他分享 >adb

adb

时间:2024-09-13 22:16:00浏览次数:8  
标签:width place tk adb root anchor

 

# coding=utf-8
import tkinter as tk
import tkinter.messagebox #这个是消息框,对话框的关键
import tkinter.constants
import os
import threading

global deviceStatus
global showStatusInfo
global bm1
global statusPic
showStatusInfo = False

secondLine = 40
thirdLine = 80

def runCmd(str):
p = os.popen(str)
return p.read()

def screenShot():
os.system("adb shell screencap -p /sdcard/screen.jpg")
os.system("adb pull /sdcard/screen.jpg")
return

def updatePic():
screenShot()
os.system("del screen.gif")
os.system("ffmpeg -i screen.jpg -s 240x425 screen.gif")
global bm1
bm1 = tk.PhotoImage(file='screen.gif')
global statusPic
statusPic.configure(imag=bm1)
return

def getDeviceStatus():
status = runCmd("adb devices").strip()
print(status)
if status=="List of devices attached":
status="当前无设备连接"
else:
status = status.replace("List of devices attached","").strip()
t1 = threading.Thread(target=updatePic)
t1.setDaemon(True)
t1.start()
deviceStatus.set(status)
global showStatusInfo
if showStatusInfo==True:
tkinter.messagebox.showinfo("提示","设备状态已更新")
showStatusInfo = True
return status

def screenOn():
os.system("adb shell input keyevent 224")
return

def screenOff():
os.system("adb shell input keyevent 223")
return

def unlockScreen():
os.system("adb shell input swipe 500 600 500 50")
return

def downSlide():
os.system("adb shell input swipe 500 50 500 600")
return

def showMac():
p = runCmd("adb shell cat /sys/class/net/wlan0/address")
tk.messagebox.showinfo("提示","Android设备MAC地址为"+p)
return

def getDensity():
p = runCmd("adb shell wm density")
tk.messagebox.showinfo("提示","屏幕密度为"+p)
return

def getScreenSize():
p = runCmd("adb shell wm size")
tk.messagebox.showinfo("提示","android设备屏幕分辩率"+p)
return

def getWifi():
p = runCmd("adb shell cat /data/misc/wifi/*.conf")
list = p.split("network=")
i=1

########################测试代码#################################
# s=0
# while s<150:
# s+=1
# list.append(p.split("network=")[1])
########################测试代码#################################

result = ""
while i<len(list):
ssid = list[i].split("ssid=")[1].split("psk=")[0].strip()
psk = list[i].split("psk=")[1].split("key_mgmt=")[0].strip()
result =result+ "wifi名称:"+ssid+" wifi密码:"+psk+" --- "
print(result)
i+=1
tk.messagebox.showinfo("所有wifi名称和密码",result)
return

def getCurrentActivity():
p = runCmd("adb shell dumpsys window | findstr mCurrentFocus")
tk.messagebox.showinfo("当前activity",p)
return

def getAllPkg():
p = runCmd("adb shell pm list package")
# tk.messagebox.showinfo("所有应用",p)
list = p.split("\n\n")
print(list)
for s in list:
packageStr = s.split(":")
if len(packageStr)>1:
s = s.split(":")[1]
listb.insert(tkinter.constants.END,s)
return p

def getAllFile():
p = runCmd("adb shell ls /mnt/sdcard/")
list = p.split("\n\n")
print(list)
for s in list:
listFile.insert(tkinter.constants.END,s)
return

root = tk.Tk() # 初始化Tk()
root.title("ADB界面工具V1.0") # 设置窗口标题
root.geometry("1100x650") # 设置窗口大小 注意:是x 不是*
root.resizable(width=False, height=False) # 设置窗口是否可以变化长/宽,False不可变,True可变,默认为True
deviceStatus = tk.StringVar()

getDeviceStatus()
#显示当前设备状态的文本框
statusText = tk.Label(root, textvariable=deviceStatus, fg="blue",bd=2,width=50,font = 'Helvetica -16')
statusText.place(x=150, y=10, anchor='nw')

#更新当前设备状态的按钮
updateBtn = tk.Button(root, text="更新状态",bd=2,width=10,font = 'Helvetica -16',command=getDeviceStatus)
updateBtn.place(x=500, y=5, anchor='nw')

screenOnBtn = tk.Button(root, text="亮屏",bd=2,width=5,font = 'Helvetica -16',command=screenOn)
screenOnBtn.place(x=0, y=secondLine, anchor='nw')

screenOffBtn = tk.Button(root, text="灭屏",bd=2,width=5,font = 'Helvetica -16',command=screenOff)
screenOffBtn.place(x=70, y=secondLine, anchor='nw')

unlockScreenBtn = tk.Button(root, text="上滑/解锁",bd=2,width=10,font = 'Helvetica -16',command=unlockScreen)
unlockScreenBtn.place(x=140, y=secondLine, anchor='nw')

unlockScreenBtn = tk.Button(root, text="下滑",bd=2,width=5,font = 'Helvetica -16',command=downSlide)
unlockScreenBtn.place(x=260, y=secondLine, anchor='nw')

screenShotBtn = tk.Button(root, text="截屏保存",bd=2,width=10,font = 'Helvetica -16',command=screenShot)
screenShotBtn.place(x=330, y=secondLine, anchor='nw')

showMacBtn = tk.Button(root, text="查看mac地址",bd=2,width=10,font = 'Helvetica -16',command=showMac)
showMacBtn.place(x=450, y=secondLine, anchor='nw')

showMacBtn = tk.Button(root, text="查看分辨率",bd=2,width=10,font = 'Helvetica -16',command=getScreenSize)
showMacBtn.place(x=570, y=secondLine, anchor='nw')

getDensityBtn = tk.Button(root, text="查看屏幕密度",bd=2,width=10,font = 'Helvetica -16',command=getDensity)
getDensityBtn.place(x=700, y=secondLine, anchor='nw')

getDensityBtn = tk.Button(root, text="查看连接过的wifi和密码(root)",bd=2,width=25,font = 'Helvetica -16',command=getWifi)
getDensityBtn.place(x=0, y=thirdLine, anchor='nw')

getCurrentActivityBtn = tk.Button(root, text="当前activity",bd=2,width=10,font = 'Helvetica -16',command=getCurrentActivity)
getCurrentActivityBtn.place(x=260, y=thirdLine, anchor='nw')



listb = tk.Listbox(root,width=50,height=12)
listb.place(x=1, y=120, anchor='nw')

listFile = tk.Listbox(root,width=50,height=12)
listFile.place(x=460, y=120, anchor='nw')

getAllFile()

#listb.bind("<<ListboxSelect>>",mouseCallBack)
global bm1
bm1 = tk.PhotoImage(file='screen.gif')
global statusPic
statusPic = tk.Label(root, image=bm1,width=250)
statusPic.place(x=830, y=10, anchor='nw')

getAllPkg()


root.mainloop() # 进入消息循环

 


原文链接:https://blog.csdn.net/u012539700/article/details/100822647

标签:width,place,tk,adb,root,anchor
From: https://www.cnblogs.com/yangjies145/p/18412981

相关文章

  • adb卸载LG G7 ThinQ预装应用
     电脑adb连接手机adbdevicesadbdevices*daemonnotrunning;startingnowattcp:5037*daemonstartedsuccessfullyListofdevicesattachedLMG710TMdddefdd8    device查看要卸载应用的包名手机中打开对应的应用且只保留其在运行adbshell dumps......
  • win7连接手机提示ADB Interface 找不到驱动程序
    描述:准备在电脑上使用ADB命令调试手机时,发现手机驱动无法安装,如下图 解决方法:下载GoogleAndroid驱动程序链接:https://pan.baidu.com/s/16ZCp0w1DhDcf4FUNZkKs1Q?pwd=92qq提取码:92qq复制这段内容后打开百度网盘手机App,操作更方便哦1、打开计算机管理 2、更新ADB......
  • AdaBoost算法(AdbBoost Algorithm)—有监督学习方法、非概率模型、判别模型、非线性模型
    定义输入:训练数据集T={(x1......
  • adb命令控质android手机旋转屏幕
    实现adb命令控制Android手机旋转屏幕1.流程概述下面是实现adb命令控制Android手机旋转屏幕的整体流程:步骤操作步骤1连接手机到电脑步骤2启动adb命令行工具步骤3执行adb命令控制手机旋转屏幕2.操作步骤步骤1:连接手机到电脑首先,将手机通过USB线缆......
  • ADB安装及使用详解(非常详细)从零基础入门到精通,看完这一篇就够了
    文章目录一、ADB简介1、什么是adb2、为什么要用adb二、准备工具1、下载adb2、配置环境变量3、连接4、电脑打开cmd窗口三、ADB命令详解1、基本命令2、权限命令3、建立连接4、apk操作指令5、文件操作指令6、日志操作指令7、系统操作指令题外话==如何入门学习网络......
  • 安卓玩机工具-----ADB方式的刷机玩机工具“秋之盒”’ 测试各项功能预览
    秋之盒    安卓玩机工具-秋之盒是一款ADB刷机工具箱,基于谷歌ADB的一款绿色安装,具备了海量扩展模块,支持ADB刷机救砖、一键激活黑域、adb指令修复等功能,是一款开源、免费、易用的手机刷机工具!      并且是一款开源、免费、易用的图形化ADB工具箱,一切功能......
  • 如何使用adb控制手机_adb 连接手机_adb连接手机
    一、介绍AndroidDebugBridge我们一般简称为adb,它是一个非常强大的命令行工具,通过adb工具,你能够与你的android设备进行通信。使用adb命令是可以操控手机的,比如点击、滑动、输入等。在操控手机之前要先连接上手机,下面先来看下adb如何连接手机。二、下载adb工具官网下载......
  • adb获取手机电池信息
    1、获取手机电池信息adbshelldumpsysbattery字段说明CurrentBatteryServicestate:ACpowered:true#交流供电USBpowered:false#usb供电Wirelesspowered:false#无线供电Maxchargingcurrent:75000#最大充电电流......
  • adb命令使用
     1、查看连接的设备adbdevices2、多个设备下选择一个设备进入shell模式(shell模式下,linux的命令都可以用)adb-s设备名shelladb-s192.168.1.2:8888shell3、设置tcpid端口号adbtcpip88884、连接设备(1)安卓设备和电脑在同一个wifi下时,通过ip地址连接adbconnect1......
  • Adb 常用命令汇总
    打印依赖树:chmod+xgradlew&&./gradlew-q:app:dependencies>depend.txt查看顶层Activity信息:adbshelldumpsysactivitytop打印Log日志并过滤:adblogcat|grepcom.tencent.mm设备内文件导入MAC电脑指定路径下:adbpull/sdcard/aaa//Users/admin/Desktop卸载安......