Index of every page on this site: llms.txt
All skills
steelan9199 avatar

/phone-screenshot-yashu

@9e01957
Run it yourself

远程获取安卓手机截图。通过 WebSocket 连接电脑和手机(AutoJS),用户说"手机截图"即可触发截屏并自动打开。激活条件:用户消息包含"手机截图"、"截取手机屏幕"、"截屏手机"、"phone screenshot"等关键词。

  • 7 files
  • 39.5 KB
  • Updated 4 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/steelan9199/wechat-publisher/phone-screenshot-yashu

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈73 tokens for metadata: the name and description. ≈2.9k when used: this file. ≈4.1k more on demand in 3 files.

Description uses 1.8% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈143 characters, or 1.8%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

手机截图

功能概述

在 AI 聊天软件中说"手机截图",自动通过 WebSocket 通知手机(AutoJS)截屏,手机将图片二进制数据直接传回电脑,保存为 PNG 文件后打开查看。图片传输为二进制直传,不转 base64。

环境说明

  • 技能目录:$SKILL_DIR 指代本技能所在目录(包含 SKILL.md 的文件夹)。⚠️ $SKILL_DIR 仅为文档占位符,不是环境变量,执行命令时必须替换为实际绝对路径。
  • 端口:固定使用 9421(HTTP + WebSocket 共用)
  • 脚本目录:$SKILL_DIR/scripts/
  • 截图保存目录:$SKILL_DIR/screenshots/
  • Node.js:需要已安装 Node.js(>= 18),若未安装则提示用户安装后结束任务
  • 本技能运行命令时采用条件执行(前一条成功才执行下一条):
    • bash/zsh(Linux/macOS):cmd1 && cmd2
    • PowerShell 5(Windows):cmd1; if ($?) { cmd2 }
    • PowerShell 7+:&& 和 ; if ($?) { cmd2 } 均可
    • 禁止单 &

前置条件

条件 说明
电脑已安装 Node.js >= 18 运行 node -v 检查,未安装则提示用户安装
手机已安装 AutoJS 需开启截图权限和无障碍服务
电脑与手机在同一局域网 手机通过 WiFi 连接到电脑同网段
手机 AutoJS 脚本已运行 手机端运行 autojs-client.js,需配置电脑 IP
中继服务器已启动 电脑端运行 node server.js

AutoJS 简介

当需要向用户提及 AutoJS(如提示安装、运行脚本时),若用户可能不了解它,应简短介绍并附上官网链接。

  • AutoJS 是什么:一款安卓(Android)设备的自动化工具,支持用 JavaScript 编写脚本,模拟点击、滑动、截屏等手机操作,无需 root。
  • 官网:https://docs.autojs6.com/#/
  • 适用场景:本技能通过它在手机端运行一个连接脚本,接收电脑指令完成截屏并回传图片。

介绍示例(供 AI 参考语气):

AutoJS 是一款安卓自动化工具,可以用 JavaScript 脚本控制手机完成截屏、点击等操作。本技能需要它在手机端配合运行。 官网文档:https://docs.autojs6.com/#/

执行步骤

意图判定

用户消息特征 执行动作
包含"手机截图"/"截屏手机"/"截取手机屏幕"/"phone screenshot" 进入【获取手机截图】流程
包含"关闭手机截图"/"停止手机截图" 进入【关闭服务器】流程

获取手机截图

步骤 执行动作 具体命令/操作
1 环境检查:Node.js 运行 node -v。若命令不存在,提示用户安装 Node.js 18+,任务结束。
2 环境检查:依赖 检查 $SKILL_DIR/scripts/node_modules/ws 目录是否存在。若不存在,运行 cd "$SKILL_DIR/scripts" && npm install。
3 检测服务器状态 运行健康检查命令(见下方【服务器检测命令】)。返回 {"status":"ok"} 说明已运行;连接失败说明未启动。
4 判断是否需要启动 若步骤 3 返回 {"status":"ok"},跳到步骤 6。若连接失败,继续步骤 5。
5 启动服务器 将 $SKILL_DIR 替换为实际绝对路径,运行 cd "$SKILL_DIR/scripts"; if ($?) { node server.js }。必须使用非阻塞方式执行,因为服务器是长驻进程。
6 等待服务器就绪 运行 Start-Sleep -Seconds 2(Windows)或 sleep 2(Linux/macOS),等待服务器完成启动。然后再次运行步骤 3 的健康检查确认就绪。
7 检查手机连接 从步骤 3/6 的健康检查返回中读取 phone 字段。若为 disconnected,按【手机未连接提示】向用户介绍 AutoJS 并引导在手机上运行 autojs-client.js 脚本,任务结束。
8 触发截图 运行 node "$SKILL_DIR/scripts/trigger.js"。脚本输出图片的绝对路径。
9 打开图片 拿到图片路径后,必须调用 image-pixel-viewer-yashu 技能打开该图片。若用户电脑未安装该技能,先运行 npx skills add https://github.com/steelan9199/wechat-publisher/tree/main/skills/image-pixel-viewer-yashu 安装,安装完成后再调用该技能打开图片。
服务器检测命令
平台 命令
Windows (PowerShell) try { (Invoke-WebRequest -Uri "http://localhost:9421/health" -UseBasicParsing -TimeoutSec 2).Content } catch { "连接失败" }
Linux/macOS (bash) curl -s --max-time 2 http://localhost:9421/health || echo "连接失败"
手机未连接提示

当健康检查返回 phone: "disconnected" 时,按以下要点回复用户:

  1. 简短介绍 AutoJS:参考【AutoJS 简介】中的介绍示例,说明它是什么、本技能为何需要它。
  2. 附上官网:给出链接 https://docs.autojs6.com/#/ ,便于用户下载安装与查阅文档。
  3. 引导运行脚本:告知用户在手机端 AutoJS 中运行 $SKILL_DIR/scripts/autojs-client.js,并需在其中配置电脑的局域网 IP。
  4. 前置条件须满足:手机与电脑在同一局域网、AutoJS 已开启截图权限和无障碍服务。
  5. 提醒截图权限弹框的同意按钮:脚本中有一段被注释的代码(约第 18-21 行),用于自动点击截图权限弹框的"同意"按钮。不同手机的按钮文案可能不同(如"立即开始"、"允许"、"同意"等),如果用户希望自动点击同意按钮,需要根据自己手机实际的按钮文案修改 text("立即开始") 中的文字,并取消该段代码的注释;若文案不匹配会导致自动点击失效。对代码不熟悉的用户也可保持注释状态,每次手动点击同意即可。

关闭服务器

步骤 执行动作 具体命令
1 终止占用 9421 端口的进程 Windows: Get-NetTCPConnection -LocalPort 9421 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess | ForEach-Object { Stop-Process -Id $_ -Force };Linux/macOS: lsof -ti:9421 | xargs kill
2 确认已关闭 再次运行【服务器检测命令】,确认返回"连接失败"

输出格式

  • 获取成功:告知用户截图已完成,并告知图片路径及已打开查看
  • 手机未连接:按【手机未连接提示】向用户介绍 AutoJS 并引导运行手机端脚本
  • 服务器未启动:提示正在启动服务器
  • Node.js 未安装:提示用户安装 Node.js 18+

错误处理

错误场景 错误表现 处理方式
Node.js 未安装 node 命令不存在 提示用户安装 Node.js 18+
ws 依赖未安装 Cannot find module 'ws' 运行 cd scripts && npm install
手机未连接 健康检查返回 phone: "disconnected" 按【手机未连接提示】介绍 AutoJS 并附官网链接,引导运行手机端脚本
截图超时 trigger.js 返回超时错误 检查手机 AutoJS 是否在前台运行、截图权限是否已授权
端口被占用 服务器启动报 EADDRINUSE 提示用户端口 9421 被占用,可先关闭旧服务器再重启

全业务脚本索引清单

脚本 功能
$SKILL_DIR/scripts/server.js PC 端 WebSocket + HTTP 中继服务器(端口 9421),接收手机连接,提供截图触发接口
$SKILL_DIR/scripts/trigger.js AI 触发脚本,调用服务器 HTTP 接口获取截图,输出图片路径
$SKILL_DIR/scripts/autojs-client.js 手机端 AutoJS 脚本,连接服务器,收到指令后截屏并发送二进制图片
$SKILL_DIR/scripts/package.json npm 依赖配置(ws 库)

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 9e01957. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated 4 months ago
metadata
{
  "author": "牙叔教程",
  "version": "1.0.0"
}

README badge

README badge for steelan9199/wechat-publisher/phone-screenshot-yashu