保存时间:2026/4/3 15:41:36
| 工具名 | 核心能力 | 最适合你的场景 |
|---|---|---|
| vncdotool | VNC 自动化,命令行 / API 控制,抓屏 + 键鼠 | 你之前说的本机模拟、手眼结合原型 |
| PyAutoGUI | 本地键鼠模拟 + 屏幕截图,跨平台 | 本机实验,不用 VNC,直接控制自己 |
| xdotool | Linux 下的 X11 窗口 / 键鼠控制 | Ubuntu 22.04 下做本地自动化,超轻量 |
| FreeRDP | RDP 协议的开源实现,带命令行自动化接口 | 控制 Windows 远程桌面,比 VNC 更适合 Windows 环境 |
| QuickDesk | AI 原生远程桌面,内置 MCP 协议,支持 AI Agent 接入 | 直接对接大模型,不用自己写胶水层 |
| VNCRobot | 可视化 VNC 脚本录制 / 执行,支持循环、条件判断 | 快速录制操作,生成可重复执行的脚本 |
写死脚本 → 顺序执行 → 错了就停抓屏(眼)→ 大模型分析(脑)→ 生成动态动作(手)→ 执行 → 再抓屏x11vnc + xdotool(本地 VNC 服务 + 本地键鼠控制,不用远程)ollama + qwen:7b(本地大模型,完全离线)sudo apt update && sudo apt install x11vnc xdotool tesseract-ocr python3-pip
pip install vncdotool ollama
ollama pull qwen:7b # 拉取本地大模型
x11vnc -display :0 -forever -shared -nopw # 无密码,方便测试
from vncdotool import api
import subprocess
import ollama
# 1. 抓屏(眼)
def capture_screen(client):
client.captureScreen("screen.png")
# 用tesseract做OCR,提取屏幕文字
text = subprocess.check_output(["tesseract", "screen.png", "stdout"]).decode()
return text
# 2. 问本地大模型(脑)
def ask_ai(screen_text):
prompt = f"""
屏幕文字:{screen_text[:500]} # 只传前500字,避免太长
任务:打开浏览器,访问百度
要求:只返回xdotool命令,一行完成,比如"xdotool mousemove 500 300 click 1"
不要解释,只返回命令!
"""
response = ollama.chat(model="qwen:7b", messages=[{"role": "user", "content": prompt}])
return response["message"]["content"].strip()
# 3. 执行动作(手)
def execute_action(action):
subprocess.run(action, shell=True)
print(f"执行动作:{action}")
# 主循环
if __name__ == "__main__":
client = api.connect("localhost")
screen_text = capture_screen(client)
action = ask_ai(screen_text)
execute_action(action)
client.close()
Qwen-Agent 是基于 Qwen 模型的 LLM Agent 开发框架,提供指令遵循、工具调用、规划、记忆、多模态(看屏幕)、代码执行、MCP 远程控制等能力。
pip install 直接导入使用# 最小安装(仅核心框架)
pip install -U qwen-agent
# 全功能安装(含GUI、RAG、代码解释器、MCP远程控制)
pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]"
git clone https://github.com/QwenLM/Qwen-Agent.git
cd Qwen-Agent
pip install -e ./"[gui,rag,code_interpreter,mcp]"
from qwen_agent.agents import Assistant
# 1. 配置模型(云端 DashScope,有 API_KEY 即可)
llm_cfg = {
"model": "qwen-max-latest",
"model_server": "dashscope",
"api_key": "你的 DashScope API_KEY"
}
# 2. 创建智能体(启用代码解释器工具)
bot = Assistant(
llm=llm_cfg,
function_list=["code_interpreter"]
)
# 3. 对话+执行
messages = []
while True:
query = input("你:")
messages.append({"role": "user", "content": query})
for response in bot.run(messages=messages):
print("AI:", response)
messages.extend(response)
# 1. 启动本地模型服务
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3.5-7B-Instruct-VL \
--served-model-name qwen-vl \
--port 8000
# 2. Qwen-Agent 对接本地模型
llm_cfg = {
"model": "qwen-vl",
"model_server": "http://localhost:8000/v1",
"api_key": "EMPTY"
}
bot = Assistant(llm=llm_cfg)
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import register_tool
import vncdotool
# 1. 注册自定义工具:VNC 抓屏+点击
@register_tool("vnc_click")
def vnc_click(x: int, y: int):
client = vncdotool.api.connect("localhost")
client.mouseMove(x, y)
client.mouseClick(1)
client.captureScreen("screen.png")
return "点击完成,已抓屏"
# 2. 配置多模态模型
llm_cfg = {
"model": "qwen-max-latest",
"model_server": "dashscope",
"api_key": "你的 API_KEY"
}
# 3. 创建 Agent,启用 VNC 工具
bot = Assistant(
llm=llm_cfg,
function_list=["vnc_click"]
)
# 4. 让 AI 看屏幕并操作
messages = [{"role": "user", "content": "看当前屏幕,点击浏览器图标"}]
response = bot.run(messages=messages)
print(response)
帮我每天打开表格,导出数据,保存到桌面
打开浏览器,访问百度,搜索天气
while True:
1. 截图(眼)
2. 把截图发给本地Qwen(脑)
3. AI返回:点击(x,y) 或 输入文字
4. 代码执行点击/输入(手)
用户先在桌面找到 Chrome 图标,双击打开;然后在地址栏输入 www.baidu.com;然后在搜索框输入 “今天天气” 并回车。
screen_001.png、screen_002.png…xdotoolpyautoguipyautogui先点这里,再输入这个,再点那里…
点击(200,300)你的代码调用 xdotool mousemove 200 300 click 1电脑自己动TheBloke/Llama-2-7B-Chat-GGUF → 选 q4_K_M.gguf(4-bit 主流)。.gguf 文件,不用 Git 克隆整个仓库。TheBloke/Llama-2-7B-Chat-GPTQ → 选 4bit-128g 版本。# 安装 huggingface-hub
pip install huggingface-hub
# 下载 Llama-2-7B-Chat 4-bit GGUF(最常用)
huggingface-cli download TheBloke/Llama-2-7B-Chat-GGUF llama-2-7b-chat.Q4_K_M.gguf --local-dir ./models
llama-2-7b-chat.Q4_K_M.gguf → 点下载 → 存到本地文件夹。Llama 2 7B 4-bit 直接下。# 编译 llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# 运行 4-bit GGUF 模型
./main -m ./models/llama-2-7b-chat.Q4_K_M.gguf -p "你好" -t 8 -n 512
# 安装 Ollama
curl -fsSL https://ollama.com/install.sh | sh
# 运行 Llama 2 7B 4-bit
ollama run llama2:7b-chat-q4_K_M