AutoCua 0.1.8__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (581) hide show
  1. autocua-0.2.0/AutoCua/CUA_Sandbox/Win_CUA.py +1025 -0
  2. {autocua-0.1.8/AutoCua/web → autocua-0.2.0/AutoCua}/Cargo.lock +48 -0
  3. autocua-0.2.0/AutoCua/Cargo.toml +78 -0
  4. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/__init__.py +51 -3
  5. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/agent_conversation/service.py +130 -29
  6. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/agent_launcher.py +31 -25
  7. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/__init__.py +1 -1
  8. autocua-0.2.0/AutoCua/android/agent/__init__.py +27 -0
  9. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/android_use/service.rs +18 -17
  10. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/skills/service.rs +5 -5
  11. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/scratchpad/service.rs +1 -1
  12. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/service.rs +1 -1
  13. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/task_tracker/service.rs +1 -1
  14. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/back/service.rs +2 -2
  15. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/vault/service.rs +3 -3
  16. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/videoplayer/service.rs +2 -2
  17. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/service.rs +4 -4
  18. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/web_agent.rs +5 -4
  19. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/view.rs +2 -2
  20. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/tool_registry/service.rs +1 -1
  21. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/tree/element.rs +1 -1
  22. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/adb.py +7 -3
  23. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/session.py +7 -5
  24. autocua-0.2.0/AutoCua/build.rs +9 -0
  25. autocua-0.2.0/AutoCua/coder/__init__.py +29 -0
  26. autocua-0.2.0/AutoCua/coder/__main__.py +130 -0
  27. autocua-0.2.0/AutoCua/coder/controller/cli/service.rs +1720 -0
  28. autocua-0.2.0/AutoCua/coder/controller/scratchpad/service.rs +95 -0
  29. autocua-0.2.0/AutoCua/coder/controller/service.rs +1596 -0
  30. autocua-0.2.0/AutoCua/coder/controller/task_tracker/service.rs +102 -0
  31. autocua-0.2.0/AutoCua/coder/controller/tool/plan/service.rs +212 -0
  32. autocua-0.2.0/AutoCua/coder/controller/tool/web/anthropic.rs +44 -0
  33. autocua-0.2.0/AutoCua/coder/controller/tool/web/chatgpt.rs +58 -0
  34. autocua-0.2.0/AutoCua/coder/controller/tool/web/google_search.rs +61 -0
  35. autocua-0.2.0/AutoCua/coder/controller/tool/web/groq_search.rs +52 -0
  36. autocua-0.2.0/AutoCua/coder/controller/tool/web/openrouter.rs +48 -0
  37. autocua-0.2.0/AutoCua/coder/controller/tool/web/perplexity_search.rs +49 -0
  38. autocua-0.2.0/AutoCua/coder/controller/tool/web/service.rs +232 -0
  39. autocua-0.2.0/AutoCua/coder/controller/tool/web/web_agent.rs +393 -0
  40. autocua-0.2.0/AutoCua/coder/main/planner/planner.md +164 -0
  41. autocua-0.2.0/AutoCua/coder/main/service.rs +1572 -0
  42. autocua-0.2.0/AutoCua/coder/main/system_prompt.md +443 -0
  43. autocua-0.2.0/AutoCua/coder/main/view.rs +757 -0
  44. autocua-0.2.0/AutoCua/coder/sandbox/service.rs +866 -0
  45. autocua-0.2.0/AutoCua/coder/subagent/__init__.py +1 -0
  46. autocua-0.2.0/AutoCua/coder/subagent/__main__.py +79 -0
  47. autocua-0.2.0/AutoCua/coder/subagent/critic/critic.md +69 -0
  48. autocua-0.2.0/AutoCua/coder/subagent/service.rs +709 -0
  49. autocua-0.2.0/AutoCua/coder/subagent/system_prompt.md +390 -0
  50. autocua-0.2.0/AutoCua/coder/subagent/workflow/workflow.md +72 -0
  51. autocua-0.2.0/AutoCua/coder/tool_registry/service.rs +1772 -0
  52. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/desktop/main.js +9 -4
  53. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/desktop/package-lock.json +7 -7
  54. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/desktop/package.json +1 -1
  55. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/service.py +2 -2
  56. {autocua-0.1.8/AutoCua/mac → autocua-0.2.0/AutoCua/ios}/controller/tool/web/web_agent.py +1 -1
  57. autocua-0.2.0/AutoCua/ios_connector/__init__.py +3 -0
  58. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/session.py +11 -2
  59. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/setup.py +48 -66
  60. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/setup_server.py +11 -8
  61. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/sim_session.py +14 -22
  62. autocua-0.2.0/AutoCua/lib.rs +712 -0
  63. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/service.py +6 -1
  64. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/view.py +4 -5
  65. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/scratchpad/service.py +3 -31
  66. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/task_tracker/service.py +3 -14
  67. {autocua-0.1.8/AutoCua/mac → autocua-0.2.0/AutoCua/linux}/controller/tool/android_agent.py +11 -7
  68. {autocua-0.1.8/AutoCua/windows → autocua-0.2.0/AutoCua/linux}/controller/tool/browser_agent.py +6 -0
  69. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/service.py +2 -2
  70. {autocua-0.1.8/AutoCua/windows → autocua-0.2.0/AutoCua/linux}/controller/tool/web/web_agent.py +1 -1
  71. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/view.py +84 -719
  72. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/remote_connection/banner.py +7 -7
  73. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/remote_connection/telegram/service.py +193 -97
  74. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/remote_connection/telegram/setup.py +21 -11
  75. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/remote_connection/telegram/view.py +18 -56
  76. autocua-0.2.0/AutoCua/linux/tool_registry/service.py +365 -0
  77. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/tree/ocr.py +1 -2
  78. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/__init__.py +88 -72
  79. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/anthropic/service.py +9 -7
  80. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/anthropic/view.py +20 -5
  81. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/aws/service.py +5 -5
  82. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/aws/view.py +32 -6
  83. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/cerebras/service.py +6 -5
  84. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/cerebras/view.py +9 -3
  85. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/google/service.py +26 -11
  86. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/google/view.py +26 -17
  87. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/groq/service.py +9 -3
  88. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/groq/view.py +11 -4
  89. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/llm_manager.py +12 -5
  90. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openai/service.py +10 -10
  91. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openai/view.py +8 -4
  92. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openrouter/service.py +8 -7
  93. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openrouter/view.py +104 -43
  94. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/perplexity/service.py +6 -5
  95. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/perplexity/view.py +31 -22
  96. autocua-0.2.0/AutoCua/llm_provider/requesty/__init__.py +4 -0
  97. autocua-0.2.0/AutoCua/llm_provider/requesty/service.py +119 -0
  98. autocua-0.2.0/AutoCua/llm_provider/requesty/view.py +124 -0
  99. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/responses.py +15 -12
  100. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/together/service.py +4 -4
  101. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/together/view.py +5 -1
  102. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/service.py +6 -1
  103. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/view.py +3 -3
  104. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/scratchpad/service.py +3 -31
  105. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/task_tracker/service.py +3 -14
  106. {autocua-0.1.8/AutoCua/linux → autocua-0.2.0/AutoCua/mac}/controller/tool/android_agent.py +11 -7
  107. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/browser_agent.py +6 -0
  108. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/ios_agent.py +8 -0
  109. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/service.py +2 -2
  110. {autocua-0.1.8/AutoCua/linux → autocua-0.2.0/AutoCua/mac}/controller/tool/web/web_agent.py +1 -1
  111. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/view.py +84 -726
  112. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/remote_connection/banner.py +7 -7
  113. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/remote_connection/telegram/service.py +193 -97
  114. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/remote_connection/telegram/setup.py +21 -11
  115. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/remote_connection/telegram/view.py +18 -56
  116. autocua-0.2.0/AutoCua/mac/tool_registry/service.py +330 -0
  117. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/agent_mode.js +1 -1
  118. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/agent_mode.tsx +1 -1
  119. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/daisy_session.js +8 -5
  120. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/ios_session.js +8 -5
  121. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/cli/cli_container/coder_card.js +30 -27
  122. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/cli/cli_container/tool_icons.js +2 -1
  123. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/cli/cli_stage.js +23 -23
  124. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/css/style.css +43 -0
  125. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/device_connect/device_connect.css +19 -0
  126. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/device_connect/device_connect.js +51 -0
  127. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/index.js +1 -1
  128. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/index.tsx +1 -0
  129. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/script.js +62 -5
  130. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/service.py +197 -111
  131. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/__init__.py +4 -2
  132. autocua-0.2.0/AutoCua/utils/chrome.py +74 -0
  133. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/consent.py +1 -1
  134. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/electron.py +7 -7
  135. autocua-0.2.0/AutoCua/utils/errors.py +28 -0
  136. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/ocr_models.py +2 -2
  137. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/rust.py +48 -58
  138. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/third_party_licenses.py +32 -34
  139. autocua-0.2.0/AutoCua/utils/tls.py +118 -0
  140. autocua-0.2.0/AutoCua/utils/wda.py +58 -0
  141. autocua-0.2.0/AutoCua/web/agent/__init__.py +40 -0
  142. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/service.rs +48 -46
  143. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/view.rs +2 -2
  144. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/test.command +1 -1
  145. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/tools.js +8 -2
  146. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/bridge.rs +18 -18
  147. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/bridge_test.rs +4 -4
  148. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/browser.rs +9 -9
  149. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/page_tab_guard.rs +2 -2
  150. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/stage_bridge.rs +2 -2
  151. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/click/service.rs +2 -2
  152. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/dialog/service.rs +2 -2
  153. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/done/service.rs +3 -3
  154. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/input/service.rs +4 -4
  155. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/keyboard/service.rs +3 -3
  156. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/mod.rs +1 -1
  157. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/run_script/guardrails_check.rs +2 -2
  158. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/run_script/service.rs +3 -3
  159. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/run_script/window.rs +2 -2
  160. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/scroll/service.rs +4 -4
  161. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/service.rs +2 -2
  162. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/skills/service.rs +2 -2
  163. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/tab/service.rs +3 -3
  164. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/vault/service.rs +5 -5
  165. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/view.rs +4 -4
  166. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/wait/service.rs +3 -3
  167. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/tool_registry/service.rs +2 -2
  168. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/tree/element.rs +1 -1
  169. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/service.py +6 -1
  170. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/view.py +4 -5
  171. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/scratchpad/service.py +3 -31
  172. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/task_tracker/service.py +3 -14
  173. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/android_agent.py +11 -7
  174. {autocua-0.1.8/AutoCua/linux → autocua-0.2.0/AutoCua/windows}/controller/tool/browser_agent.py +6 -0
  175. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/service.py +2 -2
  176. autocua-0.2.0/AutoCua/windows/controller/tool/web/web.md +24 -0
  177. {autocua-0.1.8/AutoCua/ios → autocua-0.2.0/AutoCua/windows}/controller/tool/web/web_agent.py +1 -1
  178. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/view.py +83 -720
  179. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/banner.py +6 -6
  180. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/telegram/service.py +214 -137
  181. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/telegram/setup.py +21 -11
  182. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/telegram/view.py +18 -56
  183. autocua-0.2.0/AutoCua/windows/tool_registry/service.py +292 -0
  184. {autocua-0.1.8 → autocua-0.2.0}/PKG-INFO +152 -112
  185. {autocua-0.1.8 → autocua-0.2.0}/README.md +149 -109
  186. {autocua-0.1.8 → autocua-0.2.0}/THIRD_PARTY_LICENSES.txt +62 -76
  187. {autocua-0.1.8 → autocua-0.2.0}/THIRD_PARTY_NOTICES.md +66 -98
  188. {autocua-0.1.8 → autocua-0.2.0}/pyproject.toml +24 -37
  189. autocua-0.1.8/AutoCua/android/Cargo.lock +0 -584
  190. autocua-0.1.8/AutoCua/android/Cargo.toml +0 -58
  191. autocua-0.1.8/AutoCua/android/agent/__init__.py +0 -28
  192. autocua-0.1.8/AutoCua/android/build.rs +0 -6
  193. autocua-0.1.8/AutoCua/android/lib.rs +0 -145
  194. autocua-0.1.8/AutoCua/ios_connector/__init__.py +0 -3
  195. autocua-0.1.8/AutoCua/ios_connector/index.html +0 -635
  196. autocua-0.1.8/AutoCua/linux/agent/coder/__init__.py +0 -4
  197. autocua-0.1.8/AutoCua/linux/agent/coder/__main__.py +0 -150
  198. autocua-0.1.8/AutoCua/linux/agent/coder/claude_prompt.md +0 -308
  199. autocua-0.1.8/AutoCua/linux/agent/coder/service.py +0 -1206
  200. autocua-0.1.8/AutoCua/linux/agent/coder/system_prompt.md +0 -339
  201. autocua-0.1.8/AutoCua/linux/agent/coder/view.py +0 -471
  202. autocua-0.1.8/AutoCua/linux/agent/minions/__init__.py +0 -11
  203. autocua-0.1.8/AutoCua/linux/agent/minions/__main__.py +0 -107
  204. autocua-0.1.8/AutoCua/linux/agent/minions/claude_prompt.md +0 -349
  205. autocua-0.1.8/AutoCua/linux/agent/minions/service.py +0 -598
  206. autocua-0.1.8/AutoCua/linux/agent/minions/system_prompt.md +0 -381
  207. autocua-0.1.8/AutoCua/linux/agent/minions/view.py +0 -125
  208. autocua-0.1.8/AutoCua/linux/controller/cli/__init__.py +0 -4
  209. autocua-0.1.8/AutoCua/linux/controller/cli/service.py +0 -1023
  210. autocua-0.1.8/AutoCua/linux/controller/tool/plan.py +0 -180
  211. autocua-0.1.8/AutoCua/linux/tool_registry/service.py +0 -803
  212. autocua-0.1.8/AutoCua/mac/agent/coder/__init__.py +0 -4
  213. autocua-0.1.8/AutoCua/mac/agent/coder/__main__.py +0 -150
  214. autocua-0.1.8/AutoCua/mac/agent/coder/claude_prompt.md +0 -308
  215. autocua-0.1.8/AutoCua/mac/agent/coder/service.py +0 -1206
  216. autocua-0.1.8/AutoCua/mac/agent/coder/system_prompt.md +0 -339
  217. autocua-0.1.8/AutoCua/mac/agent/coder/view.py +0 -471
  218. autocua-0.1.8/AutoCua/mac/agent/minions/__init__.py +0 -11
  219. autocua-0.1.8/AutoCua/mac/agent/minions/__main__.py +0 -107
  220. autocua-0.1.8/AutoCua/mac/agent/minions/claude_prompt.md +0 -349
  221. autocua-0.1.8/AutoCua/mac/agent/minions/service.py +0 -598
  222. autocua-0.1.8/AutoCua/mac/agent/minions/system_prompt.md +0 -381
  223. autocua-0.1.8/AutoCua/mac/agent/minions/view.py +0 -125
  224. autocua-0.1.8/AutoCua/mac/controller/cli/__init__.py +0 -4
  225. autocua-0.1.8/AutoCua/mac/controller/cli/service.py +0 -1023
  226. autocua-0.1.8/AutoCua/mac/controller/tool/plan.py +0 -180
  227. autocua-0.1.8/AutoCua/mac/tool_registry/service.py +0 -768
  228. autocua-0.1.8/AutoCua/utils/chrome.py +0 -296
  229. autocua-0.1.8/AutoCua/utils/wda.py +0 -111
  230. autocua-0.1.8/AutoCua/web/Cargo.toml +0 -53
  231. autocua-0.1.8/AutoCua/web/agent/__init__.py +0 -39
  232. autocua-0.1.8/AutoCua/web/build.rs +0 -5
  233. autocua-0.1.8/AutoCua/web/lib.rs +0 -210
  234. autocua-0.1.8/AutoCua/windows/agent/coder/__init__.py +0 -4
  235. autocua-0.1.8/AutoCua/windows/agent/coder/__main__.py +0 -151
  236. autocua-0.1.8/AutoCua/windows/agent/coder/claude_prompt.md +0 -309
  237. autocua-0.1.8/AutoCua/windows/agent/coder/service.py +0 -1211
  238. autocua-0.1.8/AutoCua/windows/agent/coder/system_prompt.md +0 -340
  239. autocua-0.1.8/AutoCua/windows/agent/coder/view.py +0 -639
  240. autocua-0.1.8/AutoCua/windows/agent/minions/__init__.py +0 -11
  241. autocua-0.1.8/AutoCua/windows/agent/minions/__main__.py +0 -132
  242. autocua-0.1.8/AutoCua/windows/agent/minions/claude_prompt.md +0 -349
  243. autocua-0.1.8/AutoCua/windows/agent/minions/service.py +0 -612
  244. autocua-0.1.8/AutoCua/windows/agent/minions/system_prompt.md +0 -381
  245. autocua-0.1.8/AutoCua/windows/agent/minions/view.py +0 -125
  246. autocua-0.1.8/AutoCua/windows/controller/cli/__init__.py +0 -4
  247. autocua-0.1.8/AutoCua/windows/controller/cli/service.py +0 -815
  248. autocua-0.1.8/AutoCua/windows/controller/tool/plan.py +0 -180
  249. autocua-0.1.8/AutoCua/windows/tool_registry/service.py +0 -729
  250. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/agent_conversation/__init__.py +0 -0
  251. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/__main__.py +0 -0
  252. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/android_use/claude_prompt.md +0 -0
  253. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/android_use/fast_system_prompt.md +0 -0
  254. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/android_use/system_prompt.md +0 -0
  255. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/agent/android_use/view.rs +0 -0
  256. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/open_app/service.rs +0 -0
  257. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/shell/service.rs +0 -0
  258. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/anthropic.rs +0 -0
  259. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/chatgpt.rs +0 -0
  260. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/google_search.rs +0 -0
  261. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/groq_search.rs +0 -0
  262. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/openrouter.rs +0 -0
  263. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/perplexity_search.rs +0 -0
  264. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android/controller/tool/web/web.md +0 -0
  265. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/Helper.java +0 -0
  266. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/__init__.py +0 -0
  267. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/autocua-helper.jar +0 -0
  268. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/build_helper.py +0 -0
  269. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/emulator.py +0 -0
  270. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/android_connector/stream.py +0 -0
  271. {autocua-0.1.8/AutoCua/ios → autocua-0.2.0/AutoCua/coder}/controller/tool/web/web.md +0 -0
  272. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/data_extraction.py +0 -0
  273. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/android/instagram.md +0 -0
  274. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/android/skills.json +0 -0
  275. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/ios/instagram.md +0 -0
  276. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/ios/skills.json +0 -0
  277. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/linux/browser.md +0 -0
  278. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/linux/skills.json +0 -0
  279. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/mac/browser.md +0 -0
  280. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/mac/libreoffice_calc.md +0 -0
  281. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/mac/maps.md +0 -0
  282. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/mac/skills.json +0 -0
  283. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/web/domain_skill/google_sheets.md +0 -0
  284. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/web/domain_skill/skills.json +0 -0
  285. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/web/skills/scraping.md +0 -0
  286. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/windows/browser.md +0 -0
  287. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/windows/libreoffice_calc.md +0 -0
  288. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/default_skills/windows/skills.json +0 -0
  289. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/__init__.py +0 -0
  290. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/__init__.py +0 -0
  291. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/__main__.py +0 -0
  292. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/__init__.py +0 -0
  293. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/claude_prompt.md +0 -0
  294. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/fast_system_prompt.md +0 -0
  295. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/service.py +0 -0
  296. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/system_prompt.md +0 -0
  297. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/iphone_use/view.py +0 -0
  298. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/skills/__init__.py +0 -0
  299. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/agent/skills/service.py +0 -0
  300. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/__init__.py +0 -0
  301. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/scratchpad/__init__.py +0 -0
  302. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/scratchpad/service.py +0 -0
  303. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/service.py +0 -0
  304. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/task_tracker/__init__.py +0 -0
  305. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/task_tracker/service.py +0 -0
  306. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/__init__.py +0 -0
  307. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/open_app.py +0 -0
  308. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/shell.py +0 -0
  309. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/videoplayer.py +0 -0
  310. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/anthropic.py +0 -0
  311. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/chatgpt.py +0 -0
  312. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/google_search.py +0 -0
  313. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/groq_search.py +0 -0
  314. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/openrouter.py +0 -0
  315. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/tool/web/perplexity_search.py +0 -0
  316. {autocua-0.1.8/AutoCua/linux → autocua-0.2.0/AutoCua/ios}/controller/tool/web/web.md +0 -0
  317. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/controller/view.py +0 -0
  318. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/sandbox/__init__.py +0 -0
  319. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/sandbox/service.py +0 -0
  320. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/tool_registry/__init__.py +0 -0
  321. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/tool_registry/service.py +0 -0
  322. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/tree/__init__.py +0 -0
  323. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios/tree/element.py +0 -0
  324. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/build_paths.py +0 -0
  325. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ios_connector/ddi.py +0 -0
  326. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/__init__.py +0 -0
  327. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/__init__.py +0 -0
  328. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/claude_prompt.md +0 -0
  329. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/fast_system_prompt.md +0 -0
  330. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/computer_use/system_prompt.md +0 -0
  331. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/skills/__init__.py +0 -0
  332. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/agent/skills/service.py +0 -0
  333. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/__init__.py +0 -0
  334. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/hotkey/__init__.py +0 -0
  335. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/hotkey/service.py +0 -0
  336. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/scratchpad/__init__.py +0 -0
  337. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/service.py +0 -0
  338. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/task_tracker/__init__.py +0 -0
  339. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/__init__.py +0 -0
  340. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/android_agent_child.py +0 -0
  341. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/app_script.py +0 -0
  342. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/browser_agent_child.py +0 -0
  343. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/input_portal.py +0 -0
  344. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/open_app.py +0 -0
  345. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/screenshot.py +0 -0
  346. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/shell.py +0 -0
  347. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/anthropic.py +0 -0
  348. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/chatgpt.py +0 -0
  349. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/google_search.py +0 -0
  350. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/groq_search.py +0 -0
  351. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/openrouter.py +0 -0
  352. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/controller/tool/web/perplexity_search.py +0 -0
  353. {autocua-0.1.8/AutoCua/mac → autocua-0.2.0/AutoCua/linux}/controller/tool/web/web.md +0 -0
  354. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/remote_connection/telegram/telergam_animation.html +0 -0
  355. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/sandbox/__init__.py +0 -0
  356. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/sandbox/service.py +0 -0
  357. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/tool_registry/__init__.py +0 -0
  358. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/linux/tree/element.py +0 -0
  359. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/anthropic/__init__.py +0 -0
  360. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/aws/__init__.py +0 -0
  361. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/cerebras/__init__.py +0 -0
  362. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/google/__init__.py +0 -0
  363. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/groq/__init__.py +0 -0
  364. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openai/__init__.py +0 -0
  365. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/openrouter/__init__.py +0 -0
  366. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/perplexity/__init__.py +0 -0
  367. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/llm_provider/together/__init__.py +0 -0
  368. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/agents.html +0 -0
  369. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/agents.js +0 -0
  370. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/autocua-bots.png +0 -0
  371. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/logo.html +0 -0
  372. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/logo.png +0 -0
  373. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/logo/simulation_background.mp4 +0 -0
  374. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/__init__.py +0 -0
  375. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/__init__.py +0 -0
  376. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/__init__.py +0 -0
  377. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/claude_prompt.md +0 -0
  378. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/fast_system_prompt.md +0 -0
  379. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/computer_use/system_prompt.md +0 -0
  380. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/skills/__init__.py +0 -0
  381. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/agent/skills/service.py +0 -0
  382. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/__init__.py +0 -0
  383. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/hotkey/__init__.py +0 -0
  384. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/hotkey/service.py +0 -0
  385. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/scratchpad/__init__.py +0 -0
  386. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/service.py +0 -0
  387. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/task_tracker/__init__.py +0 -0
  388. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/__init__.py +0 -0
  389. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/android_agent_child.py +0 -0
  390. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/applescript.py +0 -0
  391. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/browser_agent_child.py +0 -0
  392. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/ios_agent_child.py +0 -0
  393. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/open_app.py +0 -0
  394. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/screenshot.py +0 -0
  395. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/shell.py +0 -0
  396. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/anthropic.py +0 -0
  397. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/chatgpt.py +0 -0
  398. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/google_search.py +0 -0
  399. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/groq_search.py +0 -0
  400. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/openrouter.py +0 -0
  401. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/controller/tool/web/perplexity_search.py +0 -0
  402. {autocua-0.1.8/AutoCua/windows → autocua-0.2.0/AutoCua/mac}/controller/tool/web/web.md +0 -0
  403. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/remote_connection/telegram/telergam_animation.html +0 -0
  404. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/sandbox/__init__.py +0 -0
  405. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/sandbox/service.py +0 -0
  406. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/tool_registry/__init__.py +0 -0
  407. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/tree/__init__.py +0 -0
  408. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/tree/element.py +0 -0
  409. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/mac/tree/ocr.py +0 -0
  410. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/__init__.py +0 -0
  411. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/agent/__init__.py +0 -0
  412. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/agent/service.py +0 -0
  413. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/agent/system_prompt.md +0 -0
  414. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/controller.py +0 -0
  415. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/memory_compression/memory_tracker.py +0 -0
  416. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/__init__.py +0 -0
  417. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/agent_mode.css +0 -0
  418. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/agent_mode/android_session.js +0 -0
  419. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/autocua-eyes.webp +0 -0
  420. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/autocua-shine.webp +0 -0
  421. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/autocua.webp +0 -0
  422. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/coderuse-eyes.webp +0 -0
  423. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/coderuse-shine.webp +0 -0
  424. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/coderuse.webp +0 -0
  425. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/computeruse-eyes.webp +0 -0
  426. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/computeruse-shine.webp +0 -0
  427. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/computeruse.webp +0 -0
  428. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/minion-eyes.webp +0 -0
  429. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/minion-shine.webp +0 -0
  430. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/minion.webp +0 -0
  431. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/mobileuse-eyes.webp +0 -0
  432. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/mobileuse-shine.webp +0 -0
  433. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/mobileuse.webp +0 -0
  434. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/scraperuse-eyes.webp +0 -0
  435. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/scraperuse-shine.webp +0 -0
  436. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/scraperuse.webp +0 -0
  437. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/webuse-eyes.webp +0 -0
  438. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/webuse-shine.webp +0 -0
  439. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/bots/webuse.webp +0 -0
  440. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat/chat.css +0 -0
  441. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat/chat.js +0 -0
  442. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat/chat.tsx +0 -0
  443. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/chat_input.css +0 -0
  444. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/chat_input.js +0 -0
  445. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/chat_input.tsx +0 -0
  446. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/link_toggle.js +0 -0
  447. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/mode_bot.css +0 -0
  448. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/mode_bot.js +0 -0
  449. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/pc_button.html +0 -0
  450. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/chat_input/send_button.html +0 -0
  451. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/cli/cli_container/coder_card.css +0 -0
  452. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/cli/cli_stage.css +0 -0
  453. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/agent.css +0 -0
  454. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/agent.js +0 -0
  455. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/agent.tsx +0 -0
  456. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/bot_blink.js +0 -0
  457. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/chain_bot.css +0 -0
  458. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/chain_bot.js +0 -0
  459. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/run_reply.css +0 -0
  460. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/run_reply.js +0 -0
  461. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/tracking_progress.css +0 -0
  462. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/agent/tracking_progress.js +0 -0
  463. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/big_center_container/big_center_container.css +0 -0
  464. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/big_center_container/big_center_container.tsx +0 -0
  465. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/chat_scroll/chat_scroll.css +0 -0
  466. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/chat_scroll/chat_scroll.js +0 -0
  467. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/README.md +0 -0
  468. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/bottom_right/bottom_right.css +0 -0
  469. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/bottom_right/bottom_right.html +0 -0
  470. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/bottom_right/bottom_right.js +0 -0
  471. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/notes_stage/notes_stage.html +0 -0
  472. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/dead/notes_stage/notes_stage.js +0 -0
  473. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/globe_shell.css +0 -0
  474. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/globe_shell.js +0 -0
  475. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/run_bot.css +0 -0
  476. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/run_bot.js +0 -0
  477. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/screen.css +0 -0
  478. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/screen.js +0 -0
  479. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/screen/screen.tsx +0 -0
  480. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/sub_agents/sub_agents.css +0 -0
  481. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/sub_agents/sub_agents.js +0 -0
  482. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/user/user.css +0 -0
  483. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/user/user.js +0 -0
  484. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/container/user/user.tsx +0 -0
  485. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/index.html +0 -0
  486. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/intro_animation.css +0 -0
  487. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/intro_animation.tsx +0 -0
  488. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/left_bar/left_bar.css +0 -0
  489. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/left_bar/left_bar.js +0 -0
  490. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/left_bar/left_bar.tsx +0 -0
  491. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/left_bar/logo_mark.svg +0 -0
  492. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/markdown.py +0 -0
  493. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/memory_bar/memory_bar.css +0 -0
  494. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/memory_bar/memory_bar.js +0 -0
  495. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/memory_bar/memory_bar.tsx +0 -0
  496. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/notes_stage/notes_stage.css +0 -0
  497. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/package-lock.json +0 -0
  498. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/package.json +0 -0
  499. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/settings/settings.css +0 -0
  500. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/settings/settings.js +0 -0
  501. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/settings/settings.tsx +0 -0
  502. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/setup/setup.css +0 -0
  503. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/setup/setup.html +0 -0
  504. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/setup/setup.js +0 -0
  505. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/skills/skills.css +0 -0
  506. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/skills/skills.js +0 -0
  507. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/skills/skills.tsx +0 -0
  508. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/skills/skills_stage.tsx +0 -0
  509. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/thinking_orb/shimmer.css +0 -0
  510. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/thinking_orb/thinking_orb.js +0 -0
  511. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/tsconfig.json +0 -0
  512. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/ui/vite.config.ts +0 -0
  513. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/agent_glow.py +0 -0
  514. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/run_recorder.py +0 -0
  515. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/sim_view.html +0 -0
  516. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/sim_view.py +0 -0
  517. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/utils/video_compress.py +0 -0
  518. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/vault/__init__.py +0 -0
  519. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/vault/service.py +0 -0
  520. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/__init__.py +0 -0
  521. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/__main__.py +0 -0
  522. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/claude_prompt.md +0 -0
  523. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/fast_system_prompt.md +0 -0
  524. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/mod.rs +0 -0
  525. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/agent/main_driver/system_prompt.md +0 -0
  526. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/background.js +0 -0
  527. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/element.js +0 -0
  528. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/icon.png +0 -0
  529. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/manifest.json +0 -0
  530. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/send_button.html +0 -0
  531. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/send_button.js +0 -0
  532. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/sidepanel.html +0 -0
  533. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/sidepanel.js +0 -0
  534. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/test.html +0 -0
  535. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/test.js +0 -0
  536. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/wake.html +0 -0
  537. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/AutoCuaBridge/wake.js +0 -0
  538. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/glow/glow.css +0 -0
  539. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/glow/glow.html +0 -0
  540. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/browser/glow/glow.js +0 -0
  541. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/scratchpad/service.rs +0 -0
  542. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/controller/todo_tracker/service.rs +0 -0
  543. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/web/tree/element.config.json +0 -0
  544. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/__init__.py +0 -0
  545. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/__init__.py +0 -0
  546. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/claude_prompt.md +0 -0
  547. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/fast_system_prompt.md +0 -0
  548. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/computer_use/system_prompt.md +0 -0
  549. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/skills/__init__.py +0 -0
  550. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/agent/skills/service.py +0 -0
  551. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/__init__.py +0 -0
  552. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/hotkey/__init__.py +0 -0
  553. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/hotkey/service.py +0 -0
  554. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/scratchpad/__init__.py +0 -0
  555. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/service.py +0 -0
  556. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/task_tracker/__init__.py +0 -0
  557. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/__init__.py +0 -0
  558. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/android_agent_child.py +0 -0
  559. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/browser_agent_child.py +0 -0
  560. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/interception_toggle.ps1 +0 -0
  561. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/kernel_input.py +0 -0
  562. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/open_app.py +0 -0
  563. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/screenshot.py +0 -0
  564. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/shell.py +0 -0
  565. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/anthropic.py +0 -0
  566. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/chatgpt.py +0 -0
  567. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/google_search.py +0 -0
  568. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/groq_search.py +0 -0
  569. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/openrouter.py +0 -0
  570. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/controller/tool/web/perplexity_search.py +0 -0
  571. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/discord/service.py +0 -0
  572. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/telegram/__init__.py +0 -0
  573. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/telegram/telergam_animation.html +0 -0
  574. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/remote_connection/whatsapp/service.py +0 -0
  575. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/sandbox/__init__.py +0 -0
  576. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/sandbox/service.py +0 -0
  577. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/tool_registry/__init__.py +0 -0
  578. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/tree/__init__.py +0 -0
  579. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/tree/element.py +0 -0
  580. {autocua-0.1.8 → autocua-0.2.0}/AutoCua/windows/tree/ocr_detection.py +0 -0
  581. {autocua-0.1.8 → autocua-0.2.0}/LICENSE +0 -0
@@ -0,0 +1,1025 @@
1
+ """Second Windows: a second desktop for the agent, inside your own Windows session.
2
+
3
+ Shared with your main desktop: the same user, files, internet, installed apps
4
+ and clipboard. Its own: its windows, its focus and its picture. Nothing on it
5
+ moves your mouse or takes your keyboard, and nothing on it shows on your
6
+ screen except through the viewer window this script opens. The taskbar strip
7
+ is cropped out of every picture.
8
+
9
+ RAM: the desktop object itself is a few MB of desktop heap. Only the apps
10
+ started on it use memory, the same as opening them on your main desktop.
11
+
12
+ Standalone: Python 3 standard library and ctypes. --computer-use and --scan
13
+ also use comtypes, the UI Automation library already in the venv. No AutoCua
14
+ imports.
15
+
16
+ From D:\\AutoCua:
17
+ venv\\Scripts\\python.exe AutoCua\\CUA_Sandbox\\Win_CUA.py
18
+ Make the second desktop, start Explorer (wallpaper, icons) and
19
+ Character Map on it, and show it live in a window on your screen.
20
+ Closing the window ends everything that runs on it.
21
+ venv\\Scripts\\python.exe AutoCua\\CUA_Sandbox\\Win_CUA.py --shot AutoCua\\CUA_Sandbox\\shot.png
22
+ The same, but save one screenshot of it, print a report and exit.
23
+ venv\\Scripts\\python.exe AutoCua\\CUA_Sandbox\\Win_CUA.py --computer-use
24
+ Computer use on it with no mouse and no keyboard: scan Character Map
25
+ with UI Automation, type, click, scroll, scan again. Pictures go to
26
+ AutoCua\\CUA_Sandbox\\cu_1_scan.png and AutoCua\\CUA_Sandbox\\cu_2_after.png.
27
+ venv\\Scripts\\python.exe AutoCua\\CUA_Sandbox\\Win_CUA.py --run APP --scan scan.png
28
+ Start APP on it and save the agent's scan: what UI Automation finds
29
+ to click or type in, numbered on a picture, and print the list.
30
+
31
+ --no-shell no Explorer on it (no wallpaper or icons, least RAM)
32
+ --run CMD start CMD on it instead of Character Map (can repeat)
33
+ --wait SEC seconds the apps get to start before --shot or --scan (default 6)
34
+ """
35
+ import argparse
36
+ import ctypes
37
+ import os
38
+ import struct
39
+ import sys
40
+ import threading
41
+ import time
42
+ import traceback
43
+ import zlib
44
+ from ctypes import wintypes as wt
45
+
46
+ DESKTOP = "AutoCuaAgent" # the second desktop, inside window station WinSta0
47
+ FRAME_INTERVAL = 0.25 # seconds between two pictures for the viewer
48
+ HERE = os.path.dirname(os.path.abspath(__file__))
49
+
50
+ user32 = ctypes.WinDLL("user32", use_last_error=True)
51
+ gdi32 = ctypes.WinDLL("gdi32", use_last_error=True)
52
+ kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
53
+ advapi32 = ctypes.WinDLL("advapi32", use_last_error=True)
54
+ userenv = ctypes.WinDLL("userenv", use_last_error=True)
55
+ dwmapi = ctypes.WinDLL("dwmapi")
56
+
57
+ LRESULT = ctypes.c_ssize_t
58
+ WNDPROC = ctypes.WINFUNCTYPE(LRESULT, wt.HWND, wt.UINT, wt.WPARAM, wt.LPARAM)
59
+ WNDENUMPROC = ctypes.WINFUNCTYPE(wt.BOOL, wt.HWND, wt.LPARAM)
60
+
61
+ GENERIC_ALL = 0x10000000
62
+ CREATE_SUSPENDED = 0x00000004
63
+ CREATE_UNICODE_ENVIRONMENT = 0x00000400
64
+ TOKEN_DUPLICATE, TOKEN_QUERY = 0x0002, 0x0008
65
+ STARTF_FORCEOFFFEEDBACK = 0x00000080
66
+ STILL_ACTIVE = 259
67
+ JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000
68
+ JOB_PROCESS_ID_LIST = 3
69
+ JOB_EXTENDED_LIMITS = 9
70
+ PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
71
+ PROCESS_VM_READ = 0x0010
72
+ SM_CXSCREEN, SM_CYSCREEN = 0, 1
73
+ SPI_GETWORKAREA = 0x0030
74
+ GW_HWNDNEXT = 2
75
+ GWL_EXSTYLE = -20
76
+ WS_EX_LAYERED = 0x00080000
77
+ LWA_ALPHA = 0x2
78
+ DWMWA_EXTENDED_FRAME_BOUNDS = 9
79
+ DWMWA_CLOAKED = 14
80
+ PW_RENDERFULLCONTENT = 0x2
81
+ SRCCOPY = 0x00CC0020
82
+ DIB_RGB_COLORS = 0
83
+ HALFTONE = 4
84
+ BLACK_BRUSH, NULL_BRUSH = 4, 5
85
+ TRANSPARENT = 1
86
+ LABEL_COLOR = 0x00FF00FF # magenta, as a COLORREF (0x00BBGGRR)
87
+ WS_OVERLAPPEDWINDOW = 0x00CF0000
88
+ WS_VISIBLE = 0x10000000
89
+ WM_DESTROY, WM_PAINT, WM_ERASEBKGND, WM_TIMER = 0x0002, 0x000F, 0x0014, 0x0113
90
+ WM_CHAR, WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEWHEEL = 0x0102, 0x0200, 0x0201, 0x0202, 0x020A
91
+ EM_SETSEL = 0x00B1
92
+ MK_LBUTTON = 0x0001
93
+ CWP_SKIPINVISIBLE, CWP_SKIPTRANSPARENT = 0x0001, 0x0004
94
+ IDC_ARROW = 32512
95
+ DPI_PER_MONITOR_AWARE_V2 = -4
96
+
97
+
98
+ class BITMAPINFOHEADER(ctypes.Structure):
99
+ _fields_ = [("biSize", wt.DWORD), ("biWidth", wt.LONG), ("biHeight", wt.LONG),
100
+ ("biPlanes", wt.WORD), ("biBitCount", wt.WORD), ("biCompression", wt.DWORD),
101
+ ("biSizeImage", wt.DWORD), ("biXPelsPerMeter", wt.LONG),
102
+ ("biYPelsPerMeter", wt.LONG), ("biClrUsed", wt.DWORD), ("biClrImportant", wt.DWORD)]
103
+
104
+
105
+ class BITMAPINFO(ctypes.Structure):
106
+ _fields_ = [("bmiHeader", BITMAPINFOHEADER), ("bmiColors", wt.DWORD * 3)]
107
+
108
+
109
+ class STARTUPINFOW(ctypes.Structure):
110
+ _fields_ = [("cb", wt.DWORD), ("lpReserved", wt.LPWSTR), ("lpDesktop", wt.LPWSTR),
111
+ ("lpTitle", wt.LPWSTR), ("dwX", wt.DWORD), ("dwY", wt.DWORD),
112
+ ("dwXSize", wt.DWORD), ("dwYSize", wt.DWORD), ("dwXCountChars", wt.DWORD),
113
+ ("dwYCountChars", wt.DWORD), ("dwFillAttribute", wt.DWORD), ("dwFlags", wt.DWORD),
114
+ ("wShowWindow", wt.WORD), ("cbReserved2", wt.WORD), ("lpReserved2", ctypes.c_void_p),
115
+ ("hStdInput", wt.HANDLE), ("hStdOutput", wt.HANDLE), ("hStdError", wt.HANDLE)]
116
+
117
+
118
+ class PROCESS_INFORMATION(ctypes.Structure):
119
+ _fields_ = [("hProcess", wt.HANDLE), ("hThread", wt.HANDLE),
120
+ ("dwProcessId", wt.DWORD), ("dwThreadId", wt.DWORD)]
121
+
122
+
123
+ class JOB_BASIC_LIMITS(ctypes.Structure):
124
+ _fields_ = [("PerProcessUserTimeLimit", ctypes.c_longlong), ("PerJobUserTimeLimit", ctypes.c_longlong),
125
+ ("LimitFlags", wt.DWORD), ("MinimumWorkingSetSize", ctypes.c_size_t),
126
+ ("MaximumWorkingSetSize", ctypes.c_size_t), ("ActiveProcessLimit", wt.DWORD),
127
+ ("Affinity", ctypes.c_size_t), ("PriorityClass", wt.DWORD), ("SchedulingClass", wt.DWORD)]
128
+
129
+
130
+ class JOB_EXTENDED_LIMITS_INFO(ctypes.Structure):
131
+ _fields_ = [("BasicLimitInformation", JOB_BASIC_LIMITS), ("IoInfo", ctypes.c_ulonglong * 6),
132
+ ("ProcessMemoryLimit", ctypes.c_size_t), ("JobMemoryLimit", ctypes.c_size_t),
133
+ ("PeakProcessMemoryUsed", ctypes.c_size_t), ("PeakJobMemoryUsed", ctypes.c_size_t)]
134
+
135
+
136
+ class JOB_PROCESS_IDS(ctypes.Structure):
137
+ _fields_ = [("NumberOfAssignedProcesses", wt.DWORD), ("NumberOfProcessIdsInList", wt.DWORD),
138
+ ("ProcessIdList", ctypes.c_size_t * 512)]
139
+
140
+
141
+ class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
142
+ _fields_ = [("cb", wt.DWORD), ("PageFaultCount", wt.DWORD)] + [(name, ctypes.c_size_t) for name in (
143
+ "PeakWorkingSetSize", "WorkingSetSize", "QuotaPeakPagedPoolUsage", "QuotaPagedPoolUsage",
144
+ "QuotaPeakNonPagedPoolUsage", "QuotaNonPagedPoolUsage", "PagefileUsage",
145
+ "PeakPagefileUsage", "PrivateUsage")]
146
+
147
+
148
+ class WNDCLASSEXW(ctypes.Structure):
149
+ _fields_ = [("cbSize", wt.UINT), ("style", wt.UINT), ("lpfnWndProc", WNDPROC),
150
+ ("cbClsExtra", ctypes.c_int), ("cbWndExtra", ctypes.c_int), ("hInstance", wt.HINSTANCE),
151
+ ("hIcon", wt.HICON), ("hCursor", wt.HANDLE), ("hbrBackground", wt.HBRUSH),
152
+ ("lpszMenuName", wt.LPCWSTR), ("lpszClassName", wt.LPCWSTR), ("hIconSm", wt.HICON)]
153
+
154
+
155
+ class PAINTSTRUCT(ctypes.Structure):
156
+ _fields_ = [("hdc", wt.HDC), ("fErase", wt.BOOL), ("rcPaint", wt.RECT), ("fRestore", wt.BOOL),
157
+ ("fIncUpdate", wt.BOOL), ("rgbReserved", ctypes.c_byte * 32)]
158
+
159
+
160
+ def _api(dll, name, restype, *argtypes):
161
+ func = getattr(dll, name)
162
+ func.restype, func.argtypes = restype, argtypes
163
+ return func
164
+
165
+
166
+ P = ctypes.POINTER
167
+ VOIDP, INT = ctypes.c_void_p, ctypes.c_int
168
+
169
+ CreateDesktopW = _api(user32, "CreateDesktopW", wt.HANDLE, wt.LPCWSTR, wt.LPCWSTR, VOIDP, wt.DWORD, wt.DWORD, VOIDP)
170
+ OpenDesktopW = _api(user32, "OpenDesktopW", wt.HANDLE, wt.LPCWSTR, wt.DWORD, wt.BOOL, wt.DWORD)
171
+ CloseDesktop = _api(user32, "CloseDesktop", wt.BOOL, wt.HANDLE)
172
+ SetThreadDesktop = _api(user32, "SetThreadDesktop", wt.BOOL, wt.HANDLE)
173
+ GetTopWindow = _api(user32, "GetTopWindow", wt.HWND, wt.HWND)
174
+ GetWindow = _api(user32, "GetWindow", wt.HWND, wt.HWND, wt.UINT)
175
+ FindWindowW = _api(user32, "FindWindowW", wt.HWND, wt.LPCWSTR, wt.LPCWSTR)
176
+ FindWindowExW = _api(user32, "FindWindowExW", wt.HWND, wt.HWND, wt.HWND, wt.LPCWSTR, wt.LPCWSTR)
177
+ EnumWindows = _api(user32, "EnumWindows", wt.BOOL, WNDENUMPROC, wt.LPARAM)
178
+ EnumChildWindows = _api(user32, "EnumChildWindows", wt.BOOL, wt.HWND, WNDENUMPROC, wt.LPARAM)
179
+ IsWindowVisible = _api(user32, "IsWindowVisible", wt.BOOL, wt.HWND)
180
+ IsIconic = _api(user32, "IsIconic", wt.BOOL, wt.HWND)
181
+ GetWindowRect = _api(user32, "GetWindowRect", wt.BOOL, wt.HWND, P(wt.RECT))
182
+ GetWindowLongPtrW = _api(user32, "GetWindowLongPtrW", ctypes.c_ssize_t, wt.HWND, INT)
183
+ GetLayeredWindowAttributes = _api(user32, "GetLayeredWindowAttributes", wt.BOOL, wt.HWND, VOIDP,
184
+ P(ctypes.c_ubyte), P(wt.DWORD))
185
+ GetWindowThreadProcessId = _api(user32, "GetWindowThreadProcessId", wt.DWORD, wt.HWND, P(wt.DWORD))
186
+ GetClassNameW = _api(user32, "GetClassNameW", INT, wt.HWND, wt.LPWSTR, INT)
187
+ GetWindowTextW = _api(user32, "GetWindowTextW", INT, wt.HWND, wt.LPWSTR, INT)
188
+ GetForegroundWindow = _api(user32, "GetForegroundWindow", wt.HWND)
189
+ GetCursorPos = _api(user32, "GetCursorPos", wt.BOOL, P(wt.POINT))
190
+ WindowFromPoint = _api(user32, "WindowFromPoint", wt.HWND, wt.POINT)
191
+ ChildWindowFromPointEx = _api(user32, "ChildWindowFromPointEx", wt.HWND, wt.HWND, wt.POINT, wt.UINT)
192
+ ScreenToClient = _api(user32, "ScreenToClient", wt.BOOL, wt.HWND, P(wt.POINT))
193
+ ClientToScreen = _api(user32, "ClientToScreen", wt.BOOL, wt.HWND, P(wt.POINT))
194
+ PostMessageW = _api(user32, "PostMessageW", wt.BOOL, wt.HWND, wt.UINT, wt.WPARAM, wt.LPARAM)
195
+ PrintWindow = _api(user32, "PrintWindow", wt.BOOL, wt.HWND, wt.HDC, wt.UINT)
196
+ PaintDesktop = _api(user32, "PaintDesktop", wt.BOOL, wt.HDC)
197
+ GetDC = _api(user32, "GetDC", wt.HDC, wt.HWND)
198
+ ReleaseDC = _api(user32, "ReleaseDC", INT, wt.HWND, wt.HDC)
199
+ GetSystemMetrics = _api(user32, "GetSystemMetrics", INT, INT)
200
+ SystemParametersInfoW = _api(user32, "SystemParametersInfoW", wt.BOOL, wt.UINT, wt.UINT, VOIDP, wt.UINT)
201
+ SetProcessDpiAwarenessContext = _api(user32, "SetProcessDpiAwarenessContext", wt.BOOL, ctypes.c_ssize_t)
202
+ RegisterClassExW = _api(user32, "RegisterClassExW", wt.ATOM, P(WNDCLASSEXW))
203
+ CreateWindowExW = _api(user32, "CreateWindowExW", wt.HWND, wt.DWORD, wt.LPCWSTR, wt.LPCWSTR, wt.DWORD,
204
+ INT, INT, INT, INT, wt.HWND, wt.HMENU, wt.HINSTANCE, VOIDP)
205
+ DefWindowProcW = _api(user32, "DefWindowProcW", LRESULT, wt.HWND, wt.UINT, wt.WPARAM, wt.LPARAM)
206
+ GetMessageW = _api(user32, "GetMessageW", wt.BOOL, P(wt.MSG), wt.HWND, wt.UINT, wt.UINT)
207
+ TranslateMessage = _api(user32, "TranslateMessage", wt.BOOL, P(wt.MSG))
208
+ DispatchMessageW = _api(user32, "DispatchMessageW", LRESULT, P(wt.MSG))
209
+ PostQuitMessage = _api(user32, "PostQuitMessage", None, INT)
210
+ BeginPaint = _api(user32, "BeginPaint", wt.HDC, wt.HWND, P(PAINTSTRUCT))
211
+ EndPaint = _api(user32, "EndPaint", wt.BOOL, wt.HWND, P(PAINTSTRUCT))
212
+ GetClientRect = _api(user32, "GetClientRect", wt.BOOL, wt.HWND, P(wt.RECT))
213
+ InvalidateRect = _api(user32, "InvalidateRect", wt.BOOL, wt.HWND, VOIDP, wt.BOOL)
214
+ SetTimer = _api(user32, "SetTimer", ctypes.c_size_t, wt.HWND, ctypes.c_size_t, wt.UINT, VOIDP)
215
+ LoadCursorW = _api(user32, "LoadCursorW", wt.HANDLE, wt.HINSTANCE, VOIDP)
216
+ SetWindowTextW = _api(user32, "SetWindowTextW", wt.BOOL, wt.HWND, wt.LPCWSTR)
217
+ FillRect = _api(user32, "FillRect", INT, wt.HDC, P(wt.RECT), wt.HBRUSH)
218
+
219
+ CreateCompatibleDC = _api(gdi32, "CreateCompatibleDC", wt.HDC, wt.HDC)
220
+ CreateCompatibleBitmap = _api(gdi32, "CreateCompatibleBitmap", wt.HBITMAP, wt.HDC, INT, INT)
221
+ CreateDIBSection = _api(gdi32, "CreateDIBSection", wt.HBITMAP, wt.HDC, P(BITMAPINFO), wt.UINT,
222
+ P(VOIDP), wt.HANDLE, wt.DWORD)
223
+ SelectObject = _api(gdi32, "SelectObject", wt.HGDIOBJ, wt.HDC, wt.HGDIOBJ)
224
+ DeleteObject = _api(gdi32, "DeleteObject", wt.BOOL, wt.HGDIOBJ)
225
+ DeleteDC = _api(gdi32, "DeleteDC", wt.BOOL, wt.HDC)
226
+ BitBlt = _api(gdi32, "BitBlt", wt.BOOL, wt.HDC, INT, INT, INT, INT, wt.HDC, INT, INT, wt.DWORD)
227
+ StretchDIBits = _api(gdi32, "StretchDIBits", INT, wt.HDC, INT, INT, INT, INT, INT, INT, INT, INT,
228
+ ctypes.c_char_p, P(BITMAPINFO), wt.UINT, wt.DWORD)
229
+ SetStretchBltMode = _api(gdi32, "SetStretchBltMode", INT, wt.HDC, INT)
230
+ SetBrushOrgEx = _api(gdi32, "SetBrushOrgEx", wt.BOOL, wt.HDC, INT, INT, VOIDP)
231
+ SetWindowOrgEx = _api(gdi32, "SetWindowOrgEx", wt.BOOL, wt.HDC, INT, INT, VOIDP)
232
+ GetStockObject = _api(gdi32, "GetStockObject", wt.HGDIOBJ, INT)
233
+ GdiFlush = _api(gdi32, "GdiFlush", wt.BOOL)
234
+ CreatePen = _api(gdi32, "CreatePen", wt.HGDIOBJ, INT, INT, wt.DWORD)
235
+ CreateFontW = _api(gdi32, "CreateFontW", wt.HGDIOBJ, INT, INT, INT, INT, INT, wt.DWORD, wt.DWORD, wt.DWORD,
236
+ wt.DWORD, wt.DWORD, wt.DWORD, wt.DWORD, wt.DWORD, wt.LPCWSTR)
237
+ Rectangle = _api(gdi32, "Rectangle", wt.BOOL, wt.HDC, INT, INT, INT, INT)
238
+ SetBkMode = _api(gdi32, "SetBkMode", INT, wt.HDC, INT)
239
+ SetTextColor = _api(gdi32, "SetTextColor", wt.DWORD, wt.HDC, wt.DWORD)
240
+ TextOutW = _api(gdi32, "TextOutW", wt.BOOL, wt.HDC, INT, INT, wt.LPCWSTR, INT)
241
+
242
+ CreateProcessW = _api(kernel32, "CreateProcessW", wt.BOOL, wt.LPCWSTR, wt.LPWSTR, VOIDP, VOIDP, wt.BOOL,
243
+ wt.DWORD, VOIDP, wt.LPCWSTR, P(STARTUPINFOW), P(PROCESS_INFORMATION))
244
+ ResumeThread = _api(kernel32, "ResumeThread", wt.DWORD, wt.HANDLE)
245
+ CloseHandle = _api(kernel32, "CloseHandle", wt.BOOL, wt.HANDLE)
246
+ CreateJobObjectW = _api(kernel32, "CreateJobObjectW", wt.HANDLE, VOIDP, wt.LPCWSTR)
247
+ SetInformationJobObject = _api(kernel32, "SetInformationJobObject", wt.BOOL, wt.HANDLE, INT, VOIDP, wt.DWORD)
248
+ QueryInformationJobObject = _api(kernel32, "QueryInformationJobObject", wt.BOOL, wt.HANDLE, INT, VOIDP,
249
+ wt.DWORD, P(wt.DWORD))
250
+ AssignProcessToJobObject = _api(kernel32, "AssignProcessToJobObject", wt.BOOL, wt.HANDLE, wt.HANDLE)
251
+ TerminateJobObject = _api(kernel32, "TerminateJobObject", wt.BOOL, wt.HANDLE, wt.UINT)
252
+ OpenProcess = _api(kernel32, "OpenProcess", wt.HANDLE, wt.DWORD, wt.BOOL, wt.DWORD)
253
+ GetExitCodeProcess = _api(kernel32, "GetExitCodeProcess", wt.BOOL, wt.HANDLE, P(wt.DWORD))
254
+ QueryFullProcessImageNameW = _api(kernel32, "QueryFullProcessImageNameW", wt.BOOL, wt.HANDLE, wt.DWORD,
255
+ wt.LPWSTR, P(wt.DWORD))
256
+ K32GetProcessMemoryInfo = _api(kernel32, "K32GetProcessMemoryInfo", wt.BOOL, wt.HANDLE, VOIDP, wt.DWORD)
257
+ GetModuleHandleW = _api(kernel32, "GetModuleHandleW", wt.HMODULE, wt.LPCWSTR)
258
+ GetCurrentProcess = _api(kernel32, "GetCurrentProcess", wt.HANDLE)
259
+ OpenProcessToken = _api(advapi32, "OpenProcessToken", wt.BOOL, wt.HANDLE, wt.DWORD, P(wt.HANDLE))
260
+ CreateEnvironmentBlock = _api(userenv, "CreateEnvironmentBlock", wt.BOOL, P(VOIDP), wt.HANDLE, wt.BOOL)
261
+ DestroyEnvironmentBlock = _api(userenv, "DestroyEnvironmentBlock", wt.BOOL, VOIDP)
262
+
263
+ DwmGetWindowAttribute = _api(dwmapi, "DwmGetWindowAttribute", ctypes.c_long, wt.HWND, wt.DWORD, VOIDP, wt.DWORD)
264
+
265
+
266
+ # ---------------------------------------------------------------- the desktop
267
+
268
+ def open_desktop(name):
269
+ """The second desktop, made on first use. A desktop is a Windows object
270
+ of its own: its own windows and focus, on the same session and user."""
271
+ desk = OpenDesktopW(name, 0, False, GENERIC_ALL) or CreateDesktopW(name, None, None, 0, GENERIC_ALL, None)
272
+ if not desk:
273
+ raise ctypes.WinError(ctypes.get_last_error())
274
+ return desk
275
+
276
+
277
+ def kill_on_close_job():
278
+ """A job that ends every process in it when this script ends, however it
279
+ ends (window closed, Ctrl+C, a crash): nothing keeps running unseen."""
280
+ job = CreateJobObjectW(None, None)
281
+ info = JOB_EXTENDED_LIMITS_INFO()
282
+ info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
283
+ if not job or not SetInformationJobObject(job, JOB_EXTENDED_LIMITS, ctypes.byref(info), ctypes.sizeof(info)):
284
+ raise ctypes.WinError(ctypes.get_last_error())
285
+ return job
286
+
287
+
288
+ def fresh_environment():
289
+ """The environment Explorer gives a program, not this script's own. A
290
+ script started from an editor carries the editor's settings, and one of
291
+ Cursor's (ELECTRON_RUN_AS_NODE) turns any Electron app into plain Node."""
292
+ token, block = wt.HANDLE(), VOIDP()
293
+ if not OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE, ctypes.byref(token)):
294
+ return None
295
+ ok = CreateEnvironmentBlock(ctypes.byref(block), token, False)
296
+ CloseHandle(token)
297
+ return block if ok else None
298
+
299
+
300
+ def start_on_desktop(command, desktop, job):
301
+ """Start `command` with its windows on `desktop`. It starts suspended and
302
+ joins the job first, so whatever it starts in turn is in the job too."""
303
+ si = STARTUPINFOW()
304
+ si.cb = ctypes.sizeof(si)
305
+ si.lpDesktop = f"WinSta0\\{desktop}"
306
+ si.dwFlags = STARTF_FORCEOFFFEEDBACK # no busy cursor on your screen
307
+ pi = PROCESS_INFORMATION()
308
+ line = ctypes.create_unicode_buffer(command)
309
+ env = fresh_environment()
310
+ flags = CREATE_SUSPENDED | (CREATE_UNICODE_ENVIRONMENT if env else 0)
311
+ ok = CreateProcessW(None, line, None, None, False, flags, env, None, ctypes.byref(si), ctypes.byref(pi))
312
+ error = ctypes.get_last_error()
313
+ if env:
314
+ DestroyEnvironmentBlock(env)
315
+ if not ok:
316
+ raise ctypes.WinError(error)
317
+ AssignProcessToJobObject(job, pi.hProcess)
318
+ ResumeThread(pi.hThread)
319
+ CloseHandle(pi.hThread)
320
+ CloseHandle(pi.hProcess)
321
+ return pi.dwProcessId
322
+
323
+
324
+ def process_state(pid):
325
+ handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, False, pid)
326
+ if not handle:
327
+ return "exited"
328
+ code = wt.DWORD()
329
+ ok = GetExitCodeProcess(handle, ctypes.byref(code))
330
+ CloseHandle(handle)
331
+ return "still running" if ok and code.value == STILL_ACTIVE else f"exited (code {code.value})"
332
+
333
+
334
+ def exe_name(command):
335
+ first = command[1:].split('"', 1)[0] if command.startswith('"') else command.split()[0]
336
+ return os.path.basename(first)
337
+
338
+
339
+ # ---------------------------------------------------------------- windows
340
+
341
+ TASKBARS = ("Shell_TrayWnd", "Shell_SecondaryTrayWnd")
342
+ TASKBAR_CONTENT = "Windows.UI.Composition.DesktopWindowContentBridge"
343
+
344
+
345
+ def class_of(hwnd):
346
+ cls = ctypes.create_unicode_buffer(256)
347
+ GetClassNameW(hwnd, cls, 256)
348
+ return cls.value
349
+
350
+
351
+ def title_of(hwnd):
352
+ title = ctypes.create_unicode_buffer(256)
353
+ GetWindowTextW(hwnd, title, 256)
354
+ return title.value
355
+
356
+
357
+ def is_shown(hwnd):
358
+ """On show: visible, not minimized, not hidden by DWM, not fully clear."""
359
+ if not IsWindowVisible(hwnd) or IsIconic(hwnd):
360
+ return False
361
+ # The Windows 11 taskbar draws with XAML, which only runs on the main
362
+ # desktop: on the second desktop its window is there but empty (black).
363
+ if class_of(hwnd) in TASKBARS and not FindWindowExW(hwnd, None, TASKBAR_CONTENT, None):
364
+ return False
365
+ cloaked = wt.DWORD()
366
+ if DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED, ctypes.byref(cloaked), 4) == 0 and cloaked.value:
367
+ return False
368
+ if GetWindowLongPtrW(hwnd, GWL_EXSTYLE) & WS_EX_LAYERED:
369
+ alpha, flags = ctypes.c_ubyte(), wt.DWORD()
370
+ if (GetLayeredWindowAttributes(hwnd, None, ctypes.byref(alpha), ctypes.byref(flags))
371
+ and flags.value & LWA_ALPHA and alpha.value == 0):
372
+ return False
373
+ r = wt.RECT()
374
+ return bool(GetWindowRect(hwnd, ctypes.byref(r))) and r.right > r.left and r.bottom > r.top
375
+
376
+
377
+ def window_info(hwnd):
378
+ pid = wt.DWORD()
379
+ GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
380
+ return pid.value, class_of(hwnd), title_of(hwnd)
381
+
382
+
383
+ def process_name(pid):
384
+ handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, False, pid)
385
+ if not handle:
386
+ return f"pid {pid}"
387
+ buf, size = ctypes.create_unicode_buffer(1024), wt.DWORD(1024)
388
+ ok = QueryFullProcessImageNameW(handle, 0, buf, ctypes.byref(size))
389
+ CloseHandle(handle)
390
+ return os.path.basename(buf.value) if ok else f"pid {pid}"
391
+
392
+
393
+ def main_desktop_windows():
394
+ """The windows on show on your main desktop (this thread's desktop)."""
395
+ found = {}
396
+
397
+ @WNDENUMPROC
398
+ def collect(hwnd, _):
399
+ if is_shown(hwnd):
400
+ found[hwnd] = window_info(hwnd)
401
+ return True
402
+
403
+ EnumWindows(collect, 0)
404
+ return found
405
+
406
+
407
+ def child_windows(hwnd):
408
+ found = []
409
+
410
+ @WNDENUMPROC
411
+ def collect(child, _):
412
+ found.append(child)
413
+ return True
414
+
415
+ EnumChildWindows(hwnd, collect, 0)
416
+ return found
417
+
418
+
419
+ def job_memory(job):
420
+ """(name, private MB) for every process running in the job."""
421
+ ids = JOB_PROCESS_IDS()
422
+ if not QueryInformationJobObject(job, JOB_PROCESS_ID_LIST, ctypes.byref(ids), ctypes.sizeof(ids), None):
423
+ return []
424
+ rows = []
425
+ for pid in ids.ProcessIdList[:ids.NumberOfProcessIdsInList]:
426
+ handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ, False, pid)
427
+ if not handle:
428
+ continue
429
+ mem = PROCESS_MEMORY_COUNTERS_EX()
430
+ mem.cb = ctypes.sizeof(mem)
431
+ if K32GetProcessMemoryInfo(handle, ctypes.byref(mem), mem.cb):
432
+ rows.append((process_name(pid), mem.PrivateUsage / 2 ** 20))
433
+ CloseHandle(handle)
434
+ return rows
435
+
436
+
437
+ # ---------------------------------------------------------------- the picture
438
+
439
+ def bitmap_info(width, height):
440
+ bmi = BITMAPINFO()
441
+ h = bmi.bmiHeader
442
+ h.biSize, h.biWidth, h.biHeight = ctypes.sizeof(BITMAPINFOHEADER), width, -height # top-down rows
443
+ h.biPlanes, h.biBitCount = 1, 32
444
+ return bmi
445
+
446
+
447
+ def visible_windows():
448
+ """Top-level windows of this thread's desktop on show, top of the Z order first."""
449
+ found, hwnd = [], GetTopWindow(None)
450
+ for _ in range(5000):
451
+ if not hwnd:
452
+ break
453
+ if is_shown(hwnd):
454
+ found.append(hwnd)
455
+ hwnd = GetWindow(hwnd, GW_HWNDNEXT)
456
+ return found
457
+
458
+
459
+ def paint_window(canvas, screen, hwnd):
460
+ """Ask Windows to paint one window into `canvas` at its place on screen.
461
+ PrintWindow works for a window nobody can see, which is every window here."""
462
+ r = wt.RECT()
463
+ if not GetWindowRect(hwnd, ctypes.byref(r)):
464
+ return
465
+ w, h = r.right - r.left, r.bottom - r.top
466
+ if not (0 < w <= 16384 and 0 < h <= 16384):
467
+ return
468
+ f = wt.RECT() # the visible frame, without the invisible resize borders
469
+ if DwmGetWindowAttribute(hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, ctypes.byref(f), ctypes.sizeof(f)) != 0:
470
+ f = r
471
+ dc = CreateCompatibleDC(screen)
472
+ bmp = CreateCompatibleBitmap(screen, w, h)
473
+ old = SelectObject(dc, bmp)
474
+ if PrintWindow(hwnd, dc, PW_RENDERFULLCONTENT) or PrintWindow(hwnd, dc, 0):
475
+ BitBlt(canvas, f.left, f.top, f.right - f.left, f.bottom - f.top,
476
+ dc, f.left - r.left, f.top - r.top, SRCCOPY)
477
+ SelectObject(dc, old)
478
+ DeleteObject(bmp)
479
+ DeleteDC(dc)
480
+
481
+
482
+ def draw_boxes(canvas, boxes):
483
+ """Numbered magenta boxes, the way the agent's screenshot marks elements."""
484
+ pen = CreatePen(0, 2, LABEL_COLOR)
485
+ font = CreateFontW(-22, 0, 0, 0, 700, 0, 0, 0, 1, 0, 0, 4, 0, "Arial")
486
+ old_pen = SelectObject(canvas, pen)
487
+ old_brush = SelectObject(canvas, GetStockObject(NULL_BRUSH))
488
+ old_font = SelectObject(canvas, font)
489
+ SetBkMode(canvas, TRANSPARENT)
490
+ SetTextColor(canvas, LABEL_COLOR)
491
+ for index, (left, top, right, bottom) in boxes:
492
+ Rectangle(canvas, left, top, right, bottom)
493
+ label = f"[{index}]"
494
+ TextOutW(canvas, left + 3, top + 2, label, len(label))
495
+ SelectObject(canvas, old_font)
496
+ SelectObject(canvas, old_brush)
497
+ SelectObject(canvas, old_pen)
498
+ DeleteObject(pen)
499
+ DeleteObject(font)
500
+
501
+
502
+ def capture(x0, y0, width, height, boxes=()):
503
+ """One picture of this thread's desktop, from (x0, y0) and width x height
504
+ of it: the wallpaper, then every window on show from the bottom up, then
505
+ `boxes` as (number, (left, top, right, bottom)). Returns (top-down BGRA
506
+ bytes, windows)."""
507
+ screen = GetDC(None)
508
+ canvas = CreateCompatibleDC(screen)
509
+ bits = VOIDP()
510
+ dib = CreateDIBSection(screen, ctypes.byref(bitmap_info(width, height)), DIB_RGB_COLORS,
511
+ ctypes.byref(bits), None, 0)
512
+ old = SelectObject(canvas, dib)
513
+ SetWindowOrgEx(canvas, x0, y0, None) # draw in screen coordinates
514
+ PaintDesktop(canvas)
515
+ windows = visible_windows()
516
+ for hwnd in reversed(windows):
517
+ paint_window(canvas, screen, hwnd)
518
+ if boxes:
519
+ draw_boxes(canvas, boxes)
520
+ GdiFlush()
521
+ pixels = ctypes.string_at(bits, width * height * 4)
522
+ SelectObject(canvas, old)
523
+ DeleteObject(dib)
524
+ DeleteDC(canvas)
525
+ ReleaseDC(None, screen)
526
+ return pixels, windows
527
+
528
+
529
+ class Frames:
530
+ """The latest picture of the second desktop, shared with the viewer."""
531
+
532
+ def __init__(self, x0, y0, width, height):
533
+ self.x0, self.y0, self.width, self.height = x0, y0, width, height
534
+ self.lock = threading.Lock()
535
+ self.stop = threading.Event()
536
+ self.pixels, self.windows, self.count, self.error = None, [], 0, None
537
+
538
+
539
+ def capture_loop(desk, frames):
540
+ """Runs on a thread of its own that moves onto the second desktop: window
541
+ messages, and so PrintWindow, only reach windows on the caller's desktop."""
542
+ if not SetThreadDesktop(desk):
543
+ frames.error = f"could not join the second desktop (error {ctypes.get_last_error()})"
544
+ return
545
+ while not frames.stop.is_set():
546
+ try:
547
+ pixels, windows = capture(frames.x0, frames.y0, frames.width, frames.height)
548
+ infos = [window_info(hwnd) for hwnd in windows]
549
+ except Exception as e:
550
+ frames.error = repr(e)
551
+ return
552
+ with frames.lock:
553
+ frames.pixels, frames.windows = pixels, infos
554
+ frames.count += 1
555
+ frames.stop.wait(FRAME_INTERVAL)
556
+
557
+
558
+ def write_png(path, width, height, bgra):
559
+ """Top-down BGRA pixels to a PNG file, with the standard library's zlib."""
560
+ rgb = bytearray(width * height * 3)
561
+ rgb[0::3], rgb[1::3], rgb[2::3] = bgra[2::4], bgra[1::4], bgra[0::4]
562
+ row = width * 3
563
+ raw = b"".join(b"\x00" + rgb[y * row:(y + 1) * row] for y in range(height))
564
+
565
+ def chunk(kind, data):
566
+ return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data))
567
+
568
+ with open(path, "wb") as f:
569
+ f.write(b"\x89PNG\r\n\x1a\n"
570
+ + chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0))
571
+ + chunk(b"IDAT", zlib.compress(raw, 6)) + chunk(b"IEND", b""))
572
+
573
+
574
+ # ---------------------------------------------------------------- input without mouse or keyboard
575
+
576
+ def lparam_point(x, y):
577
+ return ((y & 0xFFFF) << 16) | (x & 0xFFFF)
578
+
579
+
580
+ def deepest_window_at(x, y):
581
+ """The innermost window under a screen point of this thread's desktop."""
582
+ hwnd = WindowFromPoint(wt.POINT(x, y))
583
+ while hwnd:
584
+ local = wt.POINT(x, y)
585
+ ScreenToClient(hwnd, ctypes.byref(local))
586
+ child = ChildWindowFromPointEx(hwnd, local, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT)
587
+ if not child or child == hwnd:
588
+ break
589
+ hwnd = child
590
+ return hwnd
591
+
592
+
593
+ def click_at(x, y):
594
+ """A left click at a screen point, sent as messages to the window under
595
+ it. For things UI Automation cannot press. The real cursor never moves."""
596
+ hwnd = deepest_window_at(x, y)
597
+ if hwnd:
598
+ local = wt.POINT(x, y)
599
+ ScreenToClient(hwnd, ctypes.byref(local))
600
+ lp = lparam_point(local.x, local.y)
601
+ PostMessageW(hwnd, WM_MOUSEMOVE, 0, lp)
602
+ PostMessageW(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, lp)
603
+ PostMessageW(hwnd, WM_LBUTTONUP, 0, lp)
604
+ return hwnd
605
+
606
+
607
+ def type_text(hwnd, text):
608
+ """Type into a window as character messages. The real keyboard is never used."""
609
+ for ch in text:
610
+ PostMessageW(hwnd, WM_CHAR, ord(ch), 1)
611
+
612
+
613
+ def scroll_at(x, y, notches):
614
+ """Mouse-wheel scroll at a screen point, as a message (down when notches > 0)."""
615
+ hwnd = deepest_window_at(x, y)
616
+ if hwnd:
617
+ PostMessageW(hwnd, WM_MOUSEWHEEL, ((-120 * notches) & 0xFFFF) << 16, lparam_point(x, y))
618
+ return hwnd
619
+
620
+
621
+ # ---------------------------------------------------------------- computer use
622
+
623
+ CUIAUTOMATION = "{ff48dba4-60ef-4201-aa87-54103eef594e}"
624
+ UIA_INVOKE, UIA_VALUE, UIA_TOGGLE = 10000, 10002, 10015
625
+ CONTROL_TYPES = {50000: "Button", 50002: "CheckBox", 50003: "ComboBox", 50004: "Edit", 50005: "Hyperlink",
626
+ 50006: "Image", 50007: "ListItem", 50008: "List", 50009: "Menu", 50010: "MenuBar",
627
+ 50011: "MenuItem", 50013: "RadioButton", 50014: "ScrollBar", 50015: "Slider", 50018: "Tab",
628
+ 50019: "TabItem", 50020: "Text", 50021: "ToolBar", 50023: "Tree", 50024: "TreeItem",
629
+ 50025: "Custom", 50026: "Group", 50027: "Thumb", 50028: "DataGrid", 50029: "DataItem",
630
+ 50030: "Document", 50031: "SplitButton", 50032: "Window", 50033: "Pane", 50037: "TitleBar"}
631
+ UIA_RECT, UIA_TYPE, UIA_NAME, UIA_FOCUSABLE, UIA_OFFSCREEN = 30001, 30003, 30005, 30009, 30022
632
+ CLICKABLE = {50000, 50002, 50003, 50004, 50005, 50007, 50011, 50013, 50015, 50019, 50024, 50029, 50031}
633
+ WHOLE_AREAS = {50030, 50032, 50033} # Document, Window, Pane: not things to click
634
+
635
+
636
+ def uia_client():
637
+ """UI Automation for the calling thread, which is already on the second desktop."""
638
+ sys.coinit_flags = 0 # COM for this thread only, multithreaded: comtypes reads it at import
639
+ import comtypes.client
640
+ lib = comtypes.client.GetModule("UIAutomationCore.dll")
641
+ return comtypes.client.CreateObject(CUIAUTOMATION, interface=lib.IUIAutomation), lib
642
+
643
+
644
+ def changed(before, after, width, rect, x0, y0):
645
+ """Share of pixels that differ inside `rect` between two pictures."""
646
+ left, top, right, bottom = rect[0] - x0, rect[1] - y0, rect[2] - x0, rect[3] - y0
647
+ diff = total = 0
648
+ for y in range(top, bottom, 4):
649
+ a = before[(y * width + left) * 4:(y * width + right) * 4]
650
+ b = after[(y * width + left) * 4:(y * width + right) * 4]
651
+ total += len(a)
652
+ diff += sum(1 for i in range(0, len(a), 16) if a[i:i + 3] != b[i:i + 3]) * 16
653
+ return diff / max(1, total)
654
+
655
+
656
+ def computer_use(desk, frames):
657
+ """The agent's loop on the second desktop, with no mouse and no keyboard:
658
+ scan with UI Automation, act on the elements directly, scan again."""
659
+ if not SetThreadDesktop(desk):
660
+ print("could not join the second desktop, error", ctypes.get_last_error())
661
+ return
662
+ uia, uia_lib = uia_client()
663
+ every = uia.CreateTrueCondition()
664
+
665
+ def pattern(element, pattern_id, interface):
666
+ found = element.GetCurrentPattern(pattern_id)
667
+ return found.QueryInterface(interface) if found else None
668
+
669
+ tops = uia.GetRootElement().FindAll(uia_lib.TreeScope_Children, every)
670
+ names = [tops.GetElement(i).CurrentName for i in range(tops.Length)]
671
+ print(f"\n1. UI Automation, from the second desktop, sees {len(names)} windows: "
672
+ + ", ".join(repr(n) for n in names))
673
+
674
+ hwnd = None
675
+ for _ in range(100):
676
+ hwnd = FindWindowW(None, "Character Map")
677
+ if hwnd:
678
+ break
679
+ time.sleep(0.1)
680
+ if not hwnd:
681
+ print("Character Map did not open on the second desktop")
682
+ return
683
+ time.sleep(1.0)
684
+ window = uia.ElementFromHandle(hwnd)
685
+
686
+ def scan(png):
687
+ found = window.FindAll(uia_lib.TreeScope_Descendants, every)
688
+ items = []
689
+ for i in range(found.Length):
690
+ e = found.GetElement(i)
691
+ r = e.CurrentBoundingRectangle
692
+ if r.right > r.left and r.bottom > r.top and not e.CurrentIsOffscreen:
693
+ items.append((e, CONTROL_TYPES.get(e.CurrentControlType, "Other"), e.CurrentName or "",
694
+ (r.left, r.top, r.right, r.bottom)))
695
+ pixels, _ = capture(frames.x0, frames.y0, frames.width, frames.height,
696
+ [(n, item[3]) for n, item in enumerate(items, 1)])
697
+ path = os.path.join(HERE, png)
698
+ write_png(path, frames.width, frames.height, pixels)
699
+ return items, path
700
+
701
+ items, path = scan("cu_1_scan.png")
702
+ print(f"2. Scan: {len(items)} elements, numbered the way the agent sees them: {path}")
703
+ for n, (_, kind, name, _) in enumerate(items, 1):
704
+ print(f" [{n}] {kind} {name!r}")
705
+
706
+ def pick(kind, words=""):
707
+ for element, k, name, rect in items:
708
+ if k == kind and words.lower() in name.lower():
709
+ return element, rect
710
+ raise LookupError(f"no {kind} {words!r} in the scan")
711
+
712
+ print("3. Act, with no mouse and no keyboard:")
713
+ edit, _ = pick("Edit")
714
+ value = pattern(edit, UIA_VALUE, uia_lib.IUIAutomationValuePattern)
715
+ edit_hwnd = edit.CurrentNativeWindowHandle
716
+
717
+ type_text(edit_hwnd, "Hi")
718
+ time.sleep(0.4)
719
+ print(f" typewrite 'Hi' (character messages) -> field: {value.CurrentValue!r}")
720
+
721
+ text = "Hello from the second desktop "
722
+ value.SetValue(text)
723
+ time.sleep(0.3)
724
+ print(f" input (UI Automation sets the field) -> field: {value.CurrentValue!r}")
725
+
726
+ grid = next((c for c in child_windows(hwnd) if "grid" in class_of(c).lower()), None)
727
+ if grid:
728
+ r, origin = wt.RECT(), wt.POINT(0, 0)
729
+ GetClientRect(grid, ctypes.byref(r))
730
+ ClientToScreen(grid, ctypes.byref(origin))
731
+ cell_w, cell_h = r.right / 20, r.bottom / 10
732
+ x, y = origin.x + int(12.5 * cell_w), origin.y + int(1.5 * cell_h) # the "A" cell
733
+ target = click_at(x, y)
734
+ time.sleep(0.4)
735
+ PostMessageW(edit_hwnd, EM_SETSEL, len(text), len(text)) # the caret to the end
736
+ select, _ = pick("Button", "Select")
737
+ pattern(select, UIA_INVOKE, uia_lib.IUIAutomationInvokePattern).Invoke()
738
+ time.sleep(0.4)
739
+ print(f" left_click at a point, cell 'A' (messages) -> went to {class_of(target)!r}")
740
+ print(f" left_click 'Select' (UI Automation Invoke) -> field: {value.CurrentValue!r}")
741
+
742
+ grid_rect = (origin.x, origin.y, origin.x + r.right, origin.y + r.bottom)
743
+ before, _ = capture(frames.x0, frames.y0, frames.width, frames.height)
744
+ scroll_at(x, y, 3)
745
+ time.sleep(0.6)
746
+ after, _ = capture(frames.x0, frames.y0, frames.width, frames.height)
747
+ share = changed(before, after, frames.width, grid_rect, frames.x0, frames.y0)
748
+ print(f" scroll down 3 (wheel messages) -> {share:.0%} of the grid changed")
749
+ if share < 0.01: # this grid ignores the wheel: press its scroll bar's button instead
750
+ down, _ = pick("Button", "Line down")
751
+ press = pattern(down, UIA_INVOKE, uia_lib.IUIAutomationInvokePattern)
752
+ for _ in range(3):
753
+ press.Invoke()
754
+ time.sleep(0.1)
755
+ time.sleep(0.5)
756
+ after, _ = capture(frames.x0, frames.y0, frames.width, frames.height)
757
+ share = changed(before, after, frames.width, grid_rect, frames.x0, frames.y0)
758
+ print(f" scroll down 3 ('Line down', UI Automation) -> {share:.0%} of the grid changed")
759
+ else:
760
+ print(" (no character grid found, point click and scroll skipped)")
761
+
762
+ box, _ = pick("CheckBox", "Advanced")
763
+ toggle = pattern(box, UIA_TOGGLE, uia_lib.IUIAutomationTogglePattern)
764
+ toggle.Toggle()
765
+ time.sleep(0.8)
766
+ print(f" left_click 'Advanced view' (UI Automation) -> {'on' if toggle.CurrentToggleState else 'off'}")
767
+
768
+ items, path = scan("cu_2_after.png")
769
+ print(f"4. Scan again: {len(items)} elements: {path}")
770
+
771
+
772
+ def scan_desktop(desk, frames, png):
773
+ """The agent's scan of the second desktop: what UI Automation finds to
774
+ click or type in, in every window on show, numbered on a picture of it.
775
+ Returns the windows on show as (pid, class, title), top first."""
776
+ if not SetThreadDesktop(desk):
777
+ raise ctypes.WinError(ctypes.get_last_error())
778
+ uia, lib = uia_client()
779
+ every = uia.CreateTrueCondition()
780
+ cache = uia.CreateCacheRequest() # these come back with the elements, in one call per window
781
+ for prop in (UIA_RECT, UIA_TYPE, UIA_NAME, UIA_FOCUSABLE, UIA_OFFSCREEN):
782
+ cache.AddProperty(prop)
783
+ windows = visible_windows()
784
+
785
+ def read():
786
+ items, above = [], []
787
+ for hwnd in windows: # top first: what a window covers is dropped from the ones below
788
+ w = wt.RECT()
789
+ GetWindowRect(hwnd, ctypes.byref(w))
790
+ try:
791
+ found = uia.ElementFromHandle(hwnd).FindAllBuildCache(lib.TreeScope_Descendants, every, cache)
792
+ except Exception as e:
793
+ print(f" could not read {class_of(hwnd)!r}: {e!r}")
794
+ found = None
795
+ for i in range(found.Length if found else 0):
796
+ e = found.GetElement(i)
797
+ kind = e.CachedControlType
798
+ if e.CachedIsOffscreen or kind in WHOLE_AREAS:
799
+ continue
800
+ if kind not in CLICKABLE and not e.CachedIsKeyboardFocusable:
801
+ continue
802
+ r = e.CachedBoundingRectangle
803
+ box = (max(r.left, w.left), max(r.top, w.top), min(r.right, w.right), min(r.bottom, w.bottom))
804
+ cx, cy = (box[0] + box[2]) // 2, (box[1] + box[3]) // 2
805
+ if box[2] - box[0] < 4 or box[3] - box[1] < 4 or any(
806
+ a.left <= cx < a.right and a.top <= cy < a.bottom for a in above):
807
+ continue
808
+ items.append((CONTROL_TYPES.get(kind, "Other"), e.CachedName or "", box))
809
+ above.append(w)
810
+ one_per_place = {}
811
+ for item in items:
812
+ one_per_place.setdefault(item[2], item)
813
+ return list(one_per_place.values())
814
+
815
+ # Chromium (so WebView2 and Electron) builds its element tree only when
816
+ # someone first asks: read until two reads in a row agree.
817
+ items = read()
818
+ for _ in range(8):
819
+ time.sleep(1.5)
820
+ start = time.monotonic()
821
+ again = read()
822
+ took = time.monotonic() - start
823
+ if len(again) == len(items):
824
+ break
825
+ items = again
826
+ items = again
827
+ pixels, _ = capture(frames.x0, frames.y0, frames.width, frames.height,
828
+ [(n, box) for n, (_, _, box) in enumerate(items, 1)])
829
+ write_png(png, frames.width, frames.height, pixels)
830
+ print(f"\nScan of the second desktop: {len(items)} elements, read in {took:.2f} s, "
831
+ f"numbered on {os.path.abspath(png)}")
832
+ for n, (kind, name, _) in enumerate(items, 1):
833
+ print(f" [{n}] {kind} {name[:50]!r}")
834
+ return [window_info(hwnd) for hwnd in windows]
835
+
836
+
837
+ # ---------------------------------------------------------------- shot and viewer
838
+
839
+ def take_shot(path, wait, frames, job, before, started):
840
+ time.sleep(wait)
841
+ seen, deadline = frames.count, time.monotonic() + 15
842
+ while frames.count == seen and frames.error is None and time.monotonic() < deadline:
843
+ time.sleep(0.05) # a picture taken after the wait
844
+ if frames.error or frames.pixels is None:
845
+ raise SystemExit(f"no picture: {frames.error or 'timed out'}")
846
+ with frames.lock:
847
+ pixels, windows = frames.pixels, frames.windows
848
+ write_png(path, frames.width, frames.height, pixels)
849
+ print(f"\nScreenshot of the second desktop: {os.path.abspath(path)} ({frames.width}x{frames.height})")
850
+ report(windows, job, before, started)
851
+
852
+
853
+ def report(windows, job, before, started):
854
+ """What runs on the second desktop, its RAM, and whether your desktop changed."""
855
+ print("Programs started on it:")
856
+ for command, pid in started:
857
+ print(f" {exe_name(command):<24} {process_state(pid)}")
858
+ print("Windows on it, top first:")
859
+ for pid, cls, title in windows:
860
+ print(f" {process_name(pid):<24} {cls:<34} {title}")
861
+ if not windows:
862
+ print(" (none)")
863
+ rows = job_memory(job)
864
+ print(f"RAM of the apps on it: {sum(mb for _, mb in rows):.0f} MB private")
865
+ for name, mb in rows:
866
+ print(f" {name:<24} {mb:7.1f} MB")
867
+ report_main_desktop(before)
868
+
869
+
870
+ def report_main_desktop(before):
871
+ windows, fg_before, fg_title, cursor = before
872
+ now, point = main_desktop_windows(), wt.POINT()
873
+ GetCursorPos(ctypes.byref(point))
874
+ new = {h: v for h, v in now.items() if h not in windows}
875
+ if new:
876
+ print("New windows on your main desktop while it ran:")
877
+ for pid, cls, title in new.values():
878
+ print(f" {process_name(pid):<24} {cls:<34} {title}")
879
+ else:
880
+ print("Your main desktop: no new windows.")
881
+ fg = GetForegroundWindow()
882
+ front = "unchanged" if fg == fg_before else f"changed from {fg_title!r} to {title_of(fg)!r}"
883
+ print(f"Your front window: {front}. Mouse: {'not moved' if (point.x, point.y) == cursor else 'moved (by you?)'}.")
884
+
885
+
886
+ def show_viewer(frames, job):
887
+ """A window on your screen that shows the second desktop live, view only."""
888
+ hinst = GetModuleHandleW(None)
889
+ bmi = bitmap_info(frames.width, frames.height)
890
+ ticks = [0]
891
+
892
+ def paint(hwnd):
893
+ ps = PAINTSTRUCT()
894
+ hdc = BeginPaint(hwnd, ctypes.byref(ps))
895
+ rc = wt.RECT()
896
+ GetClientRect(hwnd, ctypes.byref(rc))
897
+ cw, ch = rc.right, rc.bottom
898
+ black = GetStockObject(BLACK_BRUSH)
899
+ with frames.lock:
900
+ pixels = frames.pixels
901
+ if pixels is None or cw <= 0 or ch <= 0:
902
+ FillRect(hdc, ctypes.byref(rc), black)
903
+ else:
904
+ scale = min(cw / frames.width, ch / frames.height)
905
+ dw, dh = max(1, int(frames.width * scale)), max(1, int(frames.height * scale))
906
+ dx, dy = (cw - dw) // 2, (ch - dh) // 2
907
+ for bar in ((0, 0, dx, ch), (dx + dw, 0, cw, ch), (dx, 0, dx + dw, dy), (dx, dy + dh, dx + dw, ch)):
908
+ FillRect(hdc, ctypes.byref(wt.RECT(*bar)), black)
909
+ SetStretchBltMode(hdc, HALFTONE)
910
+ SetBrushOrgEx(hdc, 0, 0, None)
911
+ StretchDIBits(hdc, dx, dy, dw, dh, 0, 0, frames.width, frames.height,
912
+ pixels, ctypes.byref(bmi), DIB_RGB_COLORS, SRCCOPY)
913
+ EndPaint(hwnd, ctypes.byref(ps))
914
+
915
+ def wndproc(hwnd, msg, wparam, lparam):
916
+ try:
917
+ if msg == WM_PAINT:
918
+ paint(hwnd)
919
+ return 0
920
+ if msg == WM_ERASEBKGND:
921
+ return 1
922
+ if msg == WM_TIMER:
923
+ InvalidateRect(hwnd, None, False)
924
+ ticks[0] += 1
925
+ if ticks[0] % 8 == 1:
926
+ mb = sum(m for _, m in job_memory(job))
927
+ SetWindowTextW(hwnd, f"Second Windows - {len(frames.windows)} windows on it - "
928
+ f"its apps use {mb:.0f} MB RAM - view only")
929
+ return 0
930
+ if msg == WM_DESTROY:
931
+ PostQuitMessage(0)
932
+ return 0
933
+ except Exception as e:
934
+ print("viewer:", repr(e))
935
+ return DefWindowProcW(hwnd, msg, wparam, lparam)
936
+
937
+ proc = WNDPROC(wndproc) # kept alive for the window's whole life
938
+ wc = WNDCLASSEXW(cbSize=ctypes.sizeof(WNDCLASSEXW), lpfnWndProc=proc, hInstance=hinst,
939
+ hCursor=LoadCursorW(None, IDC_ARROW), lpszClassName="AutoCuaSecondWindows")
940
+ if not RegisterClassExW(ctypes.byref(wc)):
941
+ raise ctypes.WinError(ctypes.get_last_error())
942
+ sw, sh = GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)
943
+ w = int(sw * 0.6)
944
+ h = int(w * frames.height / frames.width) + 40
945
+ hwnd = CreateWindowExW(0, wc.lpszClassName, "Second Windows - starting", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
946
+ (sw - w) // 2, (sh - h) // 2, w, h, None, None, hinst, None)
947
+ if not hwnd:
948
+ raise ctypes.WinError(ctypes.get_last_error())
949
+ SetTimer(hwnd, 1, int(FRAME_INTERVAL * 1000), None)
950
+ msg = wt.MSG()
951
+ while GetMessageW(ctypes.byref(msg), None, 0, 0) > 0:
952
+ TranslateMessage(ctypes.byref(msg))
953
+ DispatchMessageW(ctypes.byref(msg))
954
+
955
+
956
+ def main():
957
+ parser = argparse.ArgumentParser(description="Second Windows: a second desktop for the agent.")
958
+ parser.add_argument("--shot", metavar="PNG", help="save one screenshot and exit")
959
+ parser.add_argument("--computer-use", action="store_true", help="scan and act on Character Map there")
960
+ parser.add_argument("--no-shell", action="store_true", help="no Explorer on it")
961
+ parser.add_argument("--run", action="append", metavar="CMD", help="program to start on it")
962
+ parser.add_argument("--scan", metavar="PNG", help="save the agent's scan of it and exit")
963
+ parser.add_argument("--wait", type=float, default=6.0, help="seconds before --shot or --scan")
964
+ args = parser.parse_args()
965
+ sys.stdout.reconfigure(errors="replace") # window titles can hold characters the console lacks
966
+
967
+ SetProcessDpiAwarenessContext(DPI_PER_MONITOR_AWARE_V2) # real pixels, not scaled ones
968
+ work = wt.RECT() # the screen without the taskbar strip: every picture is cropped to it
969
+ SystemParametersInfoW(SPI_GETWORKAREA, 0, ctypes.byref(work), 0)
970
+ frames = Frames(work.left, work.top, work.right - work.left, work.bottom - work.top)
971
+ windir = os.environ.get("SystemRoot", r"C:\Windows")
972
+ charmap = os.path.join(windir, "System32", "charmap.exe")
973
+ commands = [] if args.no_shell else [os.path.join(windir, "explorer.exe")]
974
+ commands += [charmap] if args.computer_use or not args.run else args.run
975
+
976
+ cursor = wt.POINT()
977
+ GetCursorPos(ctypes.byref(cursor))
978
+ front = GetForegroundWindow()
979
+ before = (main_desktop_windows(), front, title_of(front), (cursor.x, cursor.y))
980
+ desk = open_desktop(DESKTOP)
981
+ job = kill_on_close_job()
982
+ thread = threading.Thread(target=capture_loop, args=(desk, frames), daemon=True)
983
+ try:
984
+ started = []
985
+ for command in commands:
986
+ try:
987
+ started.append((command, start_on_desktop(command, DESKTOP, job)))
988
+ except OSError as e:
989
+ print(f"could not start on the second desktop: {command}: {e}")
990
+ continue
991
+ print(f"started on the second desktop: {command} (pid {started[-1][1]})")
992
+ if args.computer_use or args.scan:
993
+ if args.scan:
994
+ time.sleep(args.wait) # the apps get to start
995
+ result = []
996
+
997
+ def work(): # on a thread of its own, which moves onto the second desktop
998
+ try:
999
+ result.append(scan_desktop(desk, frames, args.scan) if args.scan else computer_use(desk, frames))
1000
+ except Exception:
1001
+ traceback.print_exc()
1002
+ worker = threading.Thread(target=work)
1003
+ worker.start()
1004
+ worker.join()
1005
+ if args.scan and result:
1006
+ report(result[0], job, before, started)
1007
+ else:
1008
+ report_main_desktop(before)
1009
+ elif args.shot:
1010
+ thread.start()
1011
+ take_shot(args.shot, args.wait, frames, job, before, started)
1012
+ else:
1013
+ thread.start()
1014
+ show_viewer(frames, job)
1015
+ finally:
1016
+ frames.stop.set()
1017
+ if thread.is_alive():
1018
+ thread.join(timeout=3)
1019
+ TerminateJobObject(job, 0)
1020
+ CloseHandle(job)
1021
+ CloseDesktop(desk)
1022
+
1023
+
1024
+ if __name__ == "__main__":
1025
+ main()