惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
I
InfoQ
小众软件
小众软件
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
美团技术团队
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
V
V2EX
J
Java Code Geeks
有赞技术团队
有赞技术团队
博客园 - 聂微东
B
Blog RSS Feed
博客园 - 司徒正美

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
"My AI Agent Kept Missing Buttons, So I Used Windows UI A...
CodeKing · 2026-05-27 · via DEV Community

The first time you let an AI agent control a desktop, it feels impressive.

Then it misses a button by 40 pixels.

Or it clicks the window behind the window. Or it types into the wrong field because a notification stole focus. Or it spends ten seconds looking at a screenshot just to decide where a textbox probably is.

That was the part of desktop automation that bothered me. The model was not really failing at reasoning. It was being forced to reverse-engineer an application from pixels.

Screenshot-first is the wrong default

The common loop looks like this:

screenshot -> model guesses UI -> model guesses coordinates -> click -> screenshot again

Enter fullscreen mode Exit fullscreen mode

It is useful as a fallback, but it is a bad default for normal desktop apps.

Most buttons, inputs, tabs, menus, and labels already exist in a semantic tree before they become pixels on the screen. The operating system exposes that tree for accessibility tools: screen readers, magnifiers, automation software, and anything else that needs to understand the UI without guessing from a bitmap.

On Windows, that layer is UI Automation.

So I stopped treating screenshots as the first source of truth.

The loop I wanted

For CliGate's desktop agent, I wanted a local loop that worked more like this:

list windows -> focus app -> find control -> set value -> send key -> read text

Enter fullscreen mode Exit fullscreen mode

That is a different kind of automation.

Instead of "click around until something happens," the agent can ask Windows for visible windows, focus the right one, find an Edit control, set its value through ValuePattern, invoke a button through UIA, or read text from a matching control.

Coordinates still exist, but they become a fallback. If the app exposes accessibility metadata, the assistant should use the semantic route first. If the app is custom-rendered, Canvas-heavy, or not exposing useful controls, then it can capture a screenshot and fall back to visual inspection.

The important rule is:

Observe semantically first. Use pixels only when the semantic layer is missing.

How I wired it into CliGate

CliGate is already a local gateway for Claude Code, Codex CLI, Gemini CLI, OpenClaw, account pools, API keys, runtime sessions, and channel workflows.

The desktop part adds a small local companion service that runs in the user's interactive desktop session. The assistant talks to it through local tools:

  • list visible windows
  • launch or focus an app
  • find one control or all matching controls
  • click a control through UIA
  • set an input value without relying on clipboard focus
  • send control keys like Enter
  • read visible text or values
  • capture a screenshot when UIA is not enough

That means the agent can stay inside one local control plane. It can work in a repo, continue a Codex or Claude Code runtime session, and still operate the desktop app that owns the last step of the workflow.

Why local matters

I do not want desktop control to depend on a hosted relay.

The desktop is full of sensitive state: open apps, browser sessions, account consoles, chat windows, clipboard contents, and local files. Keeping the control service on localhost keeps the automation close to the machine that owns that state.

It also makes the loop simpler. The assistant can inspect, act, and verify against the actual window in front of the user without shipping a stream of screenshots to a separate service.

This fits the rest of CliGate's design: local server, local dashboard, local runtime orchestration, local desktop bridge.

What changed

The big change was not speed, although UIA calls are much faster than screenshot-model-click loops.

The bigger change was reliability.

A textbox is no longer "some rectangle near the bottom of the screenshot." It is an Edit control. A button is no longer "probably the blue thing." It is a control with a name, bounding box, state, and supported patterns.

Screenshots are still useful. Some apps do not expose good accessibility metadata. Some content is graphical by nature. But for normal desktop and browser workflows, UIA-first makes the assistant feel less like a demo and more like an operator.

The project is open source here: CliGate on GitHub

If you are building desktop-capable agents, are you starting with screenshots, accessibility trees, browser automation, or something else?