I installed a background desktop driver on Windows from inside WSL2. Here is what worked and what did not.
说明与用途
作者在 WSL2 中安装了 cua-driver 背景桌面驱动程序,以在不抢占焦点的情况下控制 WeChat 窗口。读取 UI、定位元素和点击均可工作,但后台输入不支持。
问题
Desktop automation scripts often steal focus and move the cursor, breaking when run alongside a user. A background driver that can interact with the desktop without stealing focus is needed.
结果
Background reading, locating, launching, and clicking work reliably on a real Chinese-language app. Background typing does not, requiring a foreground escalation or a second machine for conversational bots.
工作流
- 1. Install cua-driver Windows executable on Windows 10.
- 2. Run the driver from a Windows process launched in WSL2.
- 3. Verify the driver opens the named pipe \\.\pipe\cua-driver and reports an attached interactive desktop.
- 4. Use the driver to read a live WeChat window (138 elements).
- 5. Perform background clicks on UI elements using stable tokens.
- 6. Observe that foreground process remains unchanged.
- 7. Attempt background typing; observe failures and error messages.
- 8. Note that a foreground escalation can temporarily bring a window to the front if needed.
证据
Reading, locating, launching without fronting, and clicking all work, on a real Chinese-language app rather than a demo.
Typing in the background does not work. cmd returned background_unavailable with the reason background input is dropped by this surface, naming the class ConsoleWindowClass.
- 记录日期: 2026-09-21T15:30:31.194Z