Windows-Use:AI 代理的图形界面自动化工具
开源项目:实现 AI 代理在 Windows GUI 层的交互能力,支持自动化桌面应用操作,为 AI 自动化提供新的可能性。
开源项目:实现 AI 代理在 Windows GUI 层的交互能力,支持自动化桌面应用操作,为 AI 自动化提供新的可能性。
Windows-Use 是一个在 GUI 层控制 Windows 的 AI Agent。它通过 Windows UI Automation API 读取屏幕,并使用任意 LLM 决定点击、输入、滚动或运行什么——不需要计算机视觉模型。
只需用自然语言告诉它任务,其余工作交给它处理。
前置要求:Python 3.10+、Windows 7/8/10/11
pip install windows-use
uv add windows-use
选择任意受支持的 LLM provider,然后运行任务:
from windows_use.providers.anthropic import ChatAnthropic
from windows_use import Agent, Browser
llm = ChatAnthropic(model="claude-sonnet-4-5")
agent = Agent(llm=llm, browser=Browser.EDGE)
agent.invoke(task="Open Notepad and write a short poem about Windows")
from windows_use.providers.openai import ChatOpenAI
from windows_use import Agent, Browser
llm = ChatOpenAI(model="gpt-4o")
agent = Agent(llm=llm, browser=Browser.CHROME)
agent.invoke(task="Search for the weather in New York on Google")
from windows_use.providers.google import ChatGoogle
from windows_use import Agent, Browser
llm = ChatGoogle(model="gemini-2.5-flash")
agent = Agent(llm=llm, browser=Browser.EDGE)
agent.invoke(task=input("Enter a task: "))
from windows_use.providers.ollama import ChatOllama
from windows_use import Agent, Browser
llm = ChatOllama(model="qwen3-vl:235b-cloud")
agent = Agent(llm=llm, use_vision=False)
agent.invoke(task=input("Enter a task: "))
import asyncio
from windows_use.providers.anthropic import ChatAnthropic
from windows_use import Agent
async def main():
llm = ChatAnthropic(model="claude-sonnet-4-5")
agent = Agent(llm=llm)
result = await agent.ainvoke(task="Take a screenshot and describe the desktop")
print(result.content)
asyncio.run(main())
直接从终端运行交互式 Agent:
windows-use
--model, -m LLM model to use
--provider, -p LLM provider
--max-steps Max steps per task (default: 200)
--debug, -d Enable debug logging
Agent(
llm=llm, # LLM instance (required)
mode="normal", # "normal" (full context) or "flash" (lightweight, faster)
browser=Browser.EDGE, # Browser.EDGE | Browser.CHROME | Browser.FIREFOX
use_vision=False, # Send screenshots to the LLM
use_annotation=False, # Annotate UI elements on screenshots
use_accessibility=True, # Use the Windows accessibility tree
auto_minimize=False, # Minimize active window before the agent starts
max_steps=25, # Max number of steps before giving up
max_consecutive_failures=3, # Abort after N consecutive tool failures
instructions=[], # Extra system instructions
secrets={}, # Key-value secrets passed to the agent context
log_to_console=True, # Print steps to the console
log_to_file=False, # Write steps to a log file
event_subscriber=None, # Custom event listener (see Events section)
experimental=False, # Enable experimental tools (file, memory, multi-select)
)
提示:使用 claude-haiku-4-、claude-sonnet-4- 或 claude-opus-4-* 可以获得最佳效果。
Agent 会自动获得这些工具,无需进行任何配置。
实验性工具(通过 experimental=True 启用):
通过事件系统观察 Agent 执行的每一步:
from windows_use import Agent, AgentEvent, EventType, BaseEventSubscriber
class MySubscriber(BaseEventSubscriber):
def invoke(self, event: AgentEvent):
if event.type == EventType.TOOL_CALL:
print(f"Tool: {event.data['tool_name']}")
elif event.type == EventType.DONE:
print(f"Done: {event.data['answer']}")
agent = Agent(llm=llm, event_subscriber=MySubscriber())
也可以使用普通的 callable:
def on_event(event: AgentEvent):
print(f"{event.type.value}: {event.data}")
agent = Agent(llm=llm, event_subscriber=on_event)
事件类型:THOUGHT · TOOL_CALL · TOOL_RESULT · DONE · ERROR
Windows-Use 支持通过多种 provider 实现语音输入和语音输出。
STT(Speech-to-Text,语音转文本):OpenAI Whisper · Google · Groq · ElevenLabs · Deepgram
TTS(Text-to-Speech,文本转语音):OpenAI · Google · Groq · ElevenLabs · Deepgram
from windows_use.providers.openai import ChatOpenAI, STTOpenAI, TTSOpenAI
from windows_use.speech import STT, TTS
llm = ChatOpenAI(model="gpt-4o")
stt = STT(provider=STTOpenAI())
tts = TTS(provider=TTSOpenAI())
task = stt.invoke() # Record and transcribe voice input
agent = Agent(llm=llm)
result = agent.invoke(task=task)
tts.invoke(result.content) # Speak the response aloud
Agent 可以原生管理 Windows 虚拟桌面:
from windows_use.vdm.core import create_desktop, switch_desktop, remove_desktop
create_desktop("Work")
switch_desktop("Work")
remove_desktop("Work")
支持 Windows 10(build 17763+)以及所有 Windows 11 版本。
本项目不提供任何沙箱或隔离层。为了保障安全:
📖 部署前请阅读完整的安全策略。
Windows-Use 包含轻量、注重隐私的遥测功能,用于帮助提高可靠性并了解真实使用情况。
你可以随时将其禁用:
ANONYMIZED_TELEMETRY=false
import os
os.environ["ANONYMIZED_TELEMETRY"] = "false"
欢迎贡献!开发工作流请参阅 CONTRIBUTING。
由 Jeomon George 用 ❤️ 打造。
@software{
author = {George, Jeomon},
title = {Windows-Use: Enable AI to control Windows OS},
year = {2025},
publisher = {GitHub},
url = {https://github.com/CursorTouch/Windows-Use}
}