Let AI agents see, open, click and type in Windows apps behind the one you are using - without taking over your screen. CLI + MCP server.
AI agents (Claude Code, Codex, Hermes, computer-use tools…) usually look at an app by switching to it and grabbing the screen. That yanks the window in front of you, and you can't use your PC until the agent is done. layershot captures the window where it is, in whatever layer of the stack, so you keep working.
> layershot list 0 FG WindowsTerminal.exe my terminal layershot shot 2 -o obsidian.png saved obsidian.png 1024x768 layer 2 Graph view - vault Your terminal stays in front and keeps keyboard focus the whole time.
Opening apps works the same way. When an agent needs an app for its own work, open_app launches it behind your windows. Most apps grab focus on startup no matter how they're launched, so layershot holds Windows' foreground lock (LockSetForegroundWindow) for the launch. Apps can't activate themselves during that time, but your own clicks and Alt+Tab still work. In our tests Paint went from holding focus for about 3.5 s to never getting it. When you ask the agent to open something, it passes front=True and the app opens normally in front.
It's pure ctypes + Pillow: no native build and no admin rights. The full technical notes (the exact Win32 calls, measurements, the Chromium blank-frame issue, and what can't be captured) are in docs/HOW-IT-WORKS.md.
The easy way: ask your agent. Paste this into Claude Code, Codex or any agent with a shell:
Install layershot from https://github.com/Kishore180994/layershot and run layershot setup.
pip install git+https://github.com/Kishore180994/layershot layershot setup layershot setup finds the agents on your PC and configures each one:
It's safe to re-run: it skips what's already there and updates the rule in place. The rule lives between / markers. layershot setup --remove takes everything back out, and --dry-run shows what would change. --agents codex,cursor limits it to those agents.
Even without setup, the MCP server sends the same rule as its server instructions, which clients like Claude Code put into the model's prompt automatically.
uvx --from git+https://github.com/Kishore180994/layershot layershot list From a clone:
git clone https://github.com/Kishore180994/layershot && cd layershot && pip install -e . Use it from an AI agent (MCP) Claude Code
claude mcp add --scope user layershot -- layershot-mcp # or without installing anything: claude mcp add --scope user layershot -- uvx --from git+https://github.com/Kishore180994/layershot layershot-mcp Claude Desktop / Cursor / any MCP client (mcpServers config):
{ "mcpServers": { "layershot": { "command": "layershot-mcp" } } } Codex (~/.codex/config.toml):
After a click, screenshot_window draws the AI's cursor on the agent's copy, so it can see where it clicked. It's a normal arrow with a blue highlight, and the same cursor appears in the AI view. It never appears anywhere else on your screen.
Custom AI cursor: point the theme at any RGBA PNG:
{ "theme": { "base": "hud", "cursor_image": "C:/path/ai_cursor.png", "cursor_hotspot": [6, 4], "cursor_height": 34 } } (in %LOCALAPPDATA%\layershot\prefs.json; cursor_hotspot is the pixel of the PNG that marks the point). Without one, the cursor's highlight follows the theme: blue for default, cyan for hud.
The first time an agent does something, a small window opens at the bottom-right of your screen showing a live picture of the window the agent is working in. It's live even while that window is behind yours, because it uses the same DWM thumbnails as taskbar previews. You also see the AI's cursor and its last actions.
Titles match loosely: "Bambu Studio" finds plate - BambuStudio (bambu-studio.exe).
The agent rule (in layershot/rules.py) is sent as MCP server instructions, and layershot setup writes it into CLAUDE.md / AGENTS.md. In short: look with screenshot_window and never switch to the window; when the agent needs an app for its own work, open_app opens it in the background; only when the user asks to open or show something does the agent use open_app(front=True) or bring_to_front. For another agent, paste the rule into its system prompt.
import layershot for w in layershot.list_windows(): print(w.layer, w.process, w.title) img, win = layershot.capture(title="Obsidian") # PIL.Image img, win = layershot.capture(2) # by layer img, win = layershot.capture(process="code.exe", keep_open=True) layershot.open_app("mspaint.exe") # background, focus stays with the user layershot.open_app(r"C:\models\part.3mf") # default app, background layershot.open_app("notepad.exe", front=True) # the user asked to see it layershot.bring_to_front(title="Bambu Studio") CLI layershot list [--json] [--no-minimized] layershot shot [--process exe] [--hwnd 0x...] [-o out.png] [--keep-open] layershot open [--front] [args...] layershot front layershot setup [--agents a,b] [--no-rules] [--remove] [--dry-run] layershot elements [--query text] layershot click [--right] [--double] layershot type "text" [--element e3] [--enter] layershot key layershot viewer [--off | --on | --quit | --hotkey "ctrl+alt+l"] layershot serve # MCP server on stdio (same as layershot-mcp) Limits Windows 10 1809+ only. PW_RENDERFULLCONTENT is needed for GPU-drawn apps. Minimized windows: while one is restored for the capture (about 0.3–1 s), it sits behind your other windows, so it can show through gaps on an uncovered part of the desktop. It never takes focus. Restore size: a window minimized from maximized comes back at its normal size for the capture, because Windows can't maximize a window without activating it. Hardware-protected content (DRM video, some games running fullscreen) captures black, the same as in any screenshot tool. Other virtual desktops: those windows are skipped by list_windows. Background opening: an app that's already open and gets reused (a URL opening as a new tab in your existing browser, for example) stays where it is. If it still manages to activate itself, layershot hands focus back to you right away. Background input can't do everything: see the table above. When an agent can't do something in the background, the rule tells it to ask you before taking over the screen. Development pip install -e . python tests/mcp_smoke.py # starts the MCP server, lists windows, captures one titled "Obsidian" python tests/test_installer.py # setup add / re-run / --remove against fake configs in a temp home Edit the title in tests/mcp_smoke.py to match a window you have open. Issues and PRs are welcome, especially for background input (see the roadmap in docs/HOW-IT-WORKS.md).
agents background claude computer-use mcp screenshot ui-automation windows
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.




