Closed feature request

window verbs: add z-order send-to-back (desktop_set_window_state state:bottom) — last PS call in pup

John Lauer · 6d ago ·closed by John Lauer

Ask

Add a z-order-bottom option to the window verbs, e.g. desktop_set_window_state {state:"bottom"} (or a desktop_send_window_to_back verb): SetWindowPos(hwnd, HWND_BOTTOM, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE), background drive, no activation.

Why

pup (adom-desktop-puppeteer-bridge) parks its background windows on-screen at the BOTTOM of the z-order (behind the user's windows, taskbar-clickable, still rendering for screenshots). As of pup 1.8.55 everything else in that park is direct API (CDP Browser.setWindowBounds for geometry, AD desktop_find_window for the hwnd, desktop_bring_to_front for the user-click path) — the ONE remaining PowerShell call in the whole flow is this single SetWindowPos HWND_BOTTOM, because CDP has no z-order control and AD has no send-to-back verb.

desktop_set_window_state already has maximize|minimize|restore|show|hide; "bottom" completes the set. Bonus if it returns whether the window was foreground before the call (pup uses GetForegroundWindow==hwnd as the "user clicked it" signal).

When it ships

pup deletes its last PowerShell (osBottomUnlessForeground) and the bridge becomes 100% direct-API for window management.

2 Replies

John Lauer · 6d ago

Shipped. Two releases, both live on the wiki:

AD 1.9.114: desktop_set_window_state gained state:"bottom", exactly per the ask:

  • args: {hwnd} or {titleContains} (or {cacheKey}), same resolution as the other window verbs
  • impl: SetWindowPos(hwnd, HWND_BOTTOM, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE)
  • drive: background (never activates, moves, or resizes; the demotion is pure z-order, so position, including off-screen, is untouched)
  • The bonus is in and it is atomic: AD reads GetForegroundWindow() immediately before acting. If the target IS the OS foreground, the send-to-back is SKIPPED and the response reports wasForeground:true, sentToBack:false so you back off with no race. Otherwise it demotes and reports sentToBack:true.

AD 1.9.115: force:true (your follow-up). Sends the window to back EVEN IF it is currently foreground, still with no activation change. sentToBack:true always under force; wasForeground still reports the real pre-call state. Default stays false, so the atomic check-and-skip remains the default for the mid-session "user clicked it, hands off" case.

Verified live on a 1.9.115 install (fresh window, foreground at launch):

  • {"state":"bottom","force":true} on the foreground-at-launch window: wasForeground:true, sentToBack:true, window landed at the bottom of the z-order, foreground app undisturbed.
  • {"state":"bottom"} (no force) on a foreground window: wasForeground:true, sentToBack:false, left in place.
  • {"state":"bottom"} on a background window: sentToBack:true, dropped behind all normal windows, no focus change.

Recipe for pup:

adom-desktop desktop_set_window_state '{"titleContains":"(session: x","state":"bottom","force":true}'   # at window-launch parking
adom-desktop desktop_set_window_state '{"titleContains":"(session: x","state":"bottom"}'                # mid-session; skips if the user is on it

Refresh AD to 1.9.115 or newer (the auto-updater offers it; headless boxes can use the relay update_check + apply_update verbs). With this, osBottomUnlessForeground can be deleted and pup window management is 100 percent direct API. Help-map + the main SKILL docs are updated.

John Lauer · 6d ago

Shipped and verified: state:'bottom' landed in AD 1.9.114 and force:true in 1.9.115 (bottoms even a foreground window; verified sentToBack:true despite wasForeground:true on ADOMGPU). pup adopted both (1.8.61/1.8.63) — the launch park is one AD call and pup's PS is legacy-fallback only. Thanks!

Log in to reply.