#!/usr/bin/env python3 import subprocess import time import os from PIL import Image ADB = os.path.expanduser('~/Android/Sdk/platform-tools/adb') OUTPUT_DIR = 'store_listing/graficos' os.makedirs(OUTPUT_DIR, exist_ok=True) # Coordenadas matemáticas para recorte simétrico 2:1 (1344 x 2688) # Pantalla nativa Pixel 8 Pro: 1344 x 2992 # Top status bar cut: 152 px # Bottom gesture bar cut: 152 px (2992 - 152 - 2688 = 152 px) CROP_BOX = (0, 152, 1344, 152 + 2688) def adb_cmd(args): cmd = [ADB] + args return subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) def capturar(nombre_archivo, descripcion): print(f"[*] Capturando {descripcion}...") time.sleep(1.5) raw = subprocess.check_output([ADB, 'exec-out', 'screencap', '-p']) temp_path = f"/tmp/{nombre_archivo}" with open(temp_path, 'wb') as f: f.write(raw) img = Image.open(temp_path) cropped = img.crop(CROP_BOX) dest_path = os.path.join(OUTPUT_DIR, nombre_archivo) cropped.save(dest_path, 'PNG') print(f" -> Guardada {dest_path} {cropped.size} (Relación 2:1 simétrica)") return dest_path def tap(x, y, desc=""): print(f"[>] Tap ({x}, {y}) - {desc}") adb_cmd(['shell', 'input', 'tap', str(x), str(y)]) time.sleep(2.5) def main(): print("=== INICIANDO AUTOMATIZACIÓN DE CAPTURAS DE PANTALLA ===") # 1. Captura 01: Login capturar("01_login.png", "Pantalla de Inicio de Sesión y Acceso Demo") # Iniciar sesión con botón demo (centro 672, 2120) tap(672, 2120, "Autocompletar e Ingresar con credenciales Demo") time.sleep(3) # 2. Captura 02: Dashboard / Inicio capturar("02_inicio.png", "Dashboard Operativo con Estadísticas y Alertas") # 3. Captura 03: Monitoreo en Tiempo Real (Pestaña 2 del bottom bar: X=504, Y=2850) tap(504, 2850, "Pestaña Monitoreo en Tiempo Real") capturar("03_monitoreo.png", "Consola de Monitoreo de Alarmas y Filtros") # 4. Captura 04: Clientes (Pestaña 3 del bottom bar: X=840, Y=2850) tap(840, 2850, "Pestaña Clientes") capturar("04_clientes.png", "Directorio y Semáforo de Clientes") # 5. Captura 05: Incidentes (Pestaña 4 del bottom bar: X=1176, Y=2850) tap(1176, 2850, "Pestaña Incidentes") capturar("05_incidentes.png", "Bitácora de Incidentes y Despacho") # 6. Captura 06: Operadores (Acceso mediante Drawer) # Abrir Drawer (botón menú en header X=80, Y=200) tap(80, 200, "Abrir Drawer lateral") time.sleep(1) # Item 4 'Operadores' en Drawer: X=350, Y=760 tap(350, 760, "Seleccionar Operadores en Drawer") time.sleep(1) capturar("06_operadores.png", "Gestión de Operadores y Turnos") print("\n[✓] Todas las 6 capturas generadas con éxito en store_listing/graficos/") if __name__ == '__main__': main()