Untitled
unknown
plain_text
a year ago
2.7 kB
10
Indexable
import tkinter as tk
from tkinter import messagebox
import subprocess
import os
import time
def get_connected_devices():
result = subprocess.run(["adb", "devices"], stdout=subprocess.PIPE)
devices = result.stdout.decode().splitlines()[1:]
device_list = [line.split()[0] for line in devices if line.strip() and "device" in line]
return device_list[:3] # Chỉ lấy 3 thiết bị đầu tiên
def open_link_on_device(device_id, url):
subprocess.run(["adb", "-s", device_id, "shell", "am", "start", "-a", "android.intent.action.VIEW", "-d", url])
def open_link_on_all_devices():
url = url_entry.get()
if not url:
messagebox.showwarning("Cảnh báo", "Vui lòng nhập URL.")
return
devices = get_connected_devices()
if len(devices) < 3:
messagebox.showerror("Lỗi", "Không tìm thấy đủ 3 thiết bị Android.")
return
for device in devices:
print(f"Mở link trên thiết bị {device}...")
open_link_on_device(device, url)
messagebox.showinfo("Thành công", "Đã mở link trên cả 3 thiết bị.")
def take_screenshot(device_id, save_path):
screenshot_file = f"/sdcard/screenshot_{device_id}.png"
subprocess.run(["adb", "-s", device_id, "shell", "screencap", "-p", screenshot_file])
subprocess.run(["adb", "-s", device_id, "pull", screenshot_file, save_path])
subprocess.run(["adb", "-s", device_id, "shell", "rm", screenshot_file])
def take_screenshots():
devices = get_connected_devices()
if len(devices) < 3:
messagebox.showerror("Lỗi", "Không tìm thấy đủ 3 thiết bị Android.")
return
timestamp = time.strftime("%Y%m%d_%H%M%S")
os.makedirs(f"screenshots/{timestamp}", exist_ok=True)
for device in devices:
save_path = f"screenshots/{timestamp}/screenshot_{device}.png"
print(f"Chụp ảnh màn hình từ thiết bị {device}...")
take_screenshot(device, save_path)
messagebox.showinfo("Thành công", "Đã chụp ảnh màn hình từ cả 3 thiết bị.")
# Giao diện
root = tk.Tk()
root.title("Chụp ảnh màn hình và mở link trên Android")
# Nhãn và ô nhập URL
url_label = tk.Label(root, text="Nhập URL:")
url_label.pack(padx=10, pady=5)
url_entry = tk.Entry(root, width=50)
url_entry.pack(padx=10, pady=5)
# Nút Mở Link
getlink_button = tk.Button(root, text="Mở Link", command=open_link_on_all_devices)
getlink_button.pack(padx=10, pady=5)
# Nút Chụp Ảnh Màn Hình
capture_button = tk.Button(root, text="Chụp Ảnh Màn Hình", command=take_screenshots)
capture_button.pack(padx=10, pady=5)
# Chạy ứng dụng
root.mainloop()Editor is loading...
Leave a Comment