#!/bin/bash # 测试:打开豆包,搜索今天去哪 DEVICE=${1:-emulator-5554} echo "=== 测试:打开豆包,搜索今天去哪 ===" echo "设备: $DEVICE" echo "" # 1. 打开豆包 echo "1. 打开豆包..." adb -s $DEVICE shell monkey -p com.bytedance.doubao -c android.intent.category.LAUNCHER 1 2>&1 | grep -v "bash arg" || { echo "⚠️ 豆包未安装,尝试安装..." echo "请先安装豆包应用" exit 1 } sleep 3 # 2. 等待应用启动 echo "2. 等待应用启动..." sleep 2 # 3. 查找搜索框并点击 echo "3. 查找搜索框..." adb -s $DEVICE shell uiautomator dump /sdcard/ui.xml 2>&1 # 查找搜索相关的元素 SEARCH_BOX=$(adb -s $DEVICE shell cat /sdcard/ui.xml | grep -iE "搜索|search|输入框|edit" | grep -oE 'bounds="\[[0-9,]+\]"' | head -1) if [ -z "$SEARCH_BOX" ]; then echo "未找到搜索框,尝试点击屏幕上方(常见搜索框位置)" adb -s $DEVICE shell input tap 540 200 else echo "找到搜索框: $SEARCH_BOX" # 提取坐标并点击 COORDS=$(echo $SEARCH_BOX | grep -oE '\[[0-9,]+\]' | head -1 | tr -d '[]') X=$(echo $COORDS | cut -d',' -f1) Y=$(echo $COORDS | cut -d',' -f2) adb -s $DEVICE shell input tap $X $Y fi sleep 1 # 4. 输入搜索关键词 echo "4. 输入搜索关键词:今天去哪" adb -s $DEVICE shell input text "jintianquna" # 拼音输入 sleep 1 # 5. 点击搜索按钮或回车 echo "5. 执行搜索..." adb -s $DEVICE shell input keyevent KEYCODE_ENTER echo "" echo "✅ 搜索命令已执行!" echo "" echo "注意:" echo "- 如果豆包未安装,请先安装豆包应用" echo "- 搜索框位置可能因应用版本而异" echo "- 中文输入可能需要使用输入法"