|
| 1 | +===================== |
| 2 | +New Features (2026-04) |
| 3 | +===================== |
| 4 | + |
| 5 | +This page documents the April 2026 additions to AutoControl. Every new |
| 6 | +feature ships with a headless Python API **and** a GUI affordance, and is |
| 7 | +wired into the executor so it works from JSON scripts, the socket server, |
| 8 | +the REST API, and the CLI without any Python glue. |
| 9 | + |
| 10 | +.. contents:: |
| 11 | + :local: |
| 12 | + :depth: 2 |
| 13 | + |
| 14 | + |
| 15 | +Clipboard |
| 16 | +========= |
| 17 | + |
| 18 | +Headless:: |
| 19 | + |
| 20 | + import je_auto_control as ac |
| 21 | + ac.set_clipboard("hello") |
| 22 | + text = ac.get_clipboard() |
| 23 | + |
| 24 | +Action-JSON commands:: |
| 25 | + |
| 26 | + [["AC_clipboard_set", {"text": "hello"}]] |
| 27 | + [["AC_clipboard_get", {}]] |
| 28 | + |
| 29 | +Backends: Windows (Win32 via ``ctypes``), macOS (``pbcopy``/``pbpaste``), |
| 30 | +Linux (``xclip`` or ``xsel``). A ``RuntimeError`` is raised if no backend |
| 31 | +is available. |
| 32 | + |
| 33 | + |
| 34 | +Dry-run / step-debug executor |
| 35 | +============================= |
| 36 | + |
| 37 | +Run an action list through the executor without invoking any side effects |
| 38 | +— useful for validating JSON scripts:: |
| 39 | + |
| 40 | + from je_auto_control.utils.executor.action_executor import executor |
| 41 | + record = executor.execute_action(actions, dry_run=True) |
| 42 | + |
| 43 | +``step_callback`` lets you observe each action before it runs:: |
| 44 | + |
| 45 | + executor.execute_action(actions, step_callback=lambda a: print(a)) |
| 46 | + |
| 47 | +From the CLI:: |
| 48 | + |
| 49 | + python -m je_auto_control.cli run script.json --dry-run |
| 50 | + |
| 51 | + |
| 52 | +Global hotkey daemon (Windows) |
| 53 | +============================== |
| 54 | + |
| 55 | +Bind OS-level hotkeys to action-JSON scripts:: |
| 56 | + |
| 57 | + from je_auto_control import default_hotkey_daemon |
| 58 | + default_hotkey_daemon.bind("ctrl+alt+1", "scripts/greet.json") |
| 59 | + default_hotkey_daemon.start() |
| 60 | + |
| 61 | +Supported modifiers: ``ctrl``, ``alt``, ``shift``, ``win`` / ``super`` / |
| 62 | +``meta``. Keys: letters, digits, ``f1`` … ``f12``, arrows, ``space``, |
| 63 | +``enter``, ``tab``, ``escape``, ``home``, ``end``, ``insert``, ``delete``, |
| 64 | +``pageup``, ``pagedown``. |
| 65 | + |
| 66 | +macOS and Linux currently raise ``NotImplementedError`` on |
| 67 | +``start()`` — the Strategy-pattern interface is in place so backends can |
| 68 | +be added later. |
| 69 | + |
| 70 | +GUI: **Hotkeys** tab (bind/unbind, start/stop daemon, live fired count). |
| 71 | + |
| 72 | + |
| 73 | +Event triggers |
| 74 | +============== |
| 75 | + |
| 76 | +Poll-based triggers fire an action script when a screen/state change is |
| 77 | +detected:: |
| 78 | + |
| 79 | + from je_auto_control import default_trigger_engine, ImageAppearsTrigger |
| 80 | + default_trigger_engine.add(ImageAppearsTrigger( |
| 81 | + trigger_id="", script_path="scripts/click_ok.json", |
| 82 | + image_path="templates/ok_button.png", threshold=0.85, |
| 83 | + repeat=True, |
| 84 | + )) |
| 85 | + default_trigger_engine.start() |
| 86 | + |
| 87 | +Available trigger types: |
| 88 | + |
| 89 | +- ``ImageAppearsTrigger`` — template match on the current screen |
| 90 | +- ``WindowAppearsTrigger`` — title substring match |
| 91 | +- ``PixelColorTrigger`` — pixel color within tolerance |
| 92 | +- ``FilePathTrigger`` — mtime change on a path |
| 93 | + |
| 94 | +GUI: **Triggers** tab (add/remove/start/stop, live fired count). |
| 95 | + |
| 96 | + |
| 97 | +Cron scheduling |
| 98 | +=============== |
| 99 | + |
| 100 | +Five-field cron (``minute hour day-of-month month day-of-week``) with |
| 101 | +``*``, comma-lists, ``*/step``, and ``start-stop`` ranges:: |
| 102 | + |
| 103 | + from je_auto_control import default_scheduler |
| 104 | + job = default_scheduler.add_cron_job( |
| 105 | + script_path="scripts/daily.json", |
| 106 | + cron_expression="0 9 * * 1-5", # 09:00 on weekdays |
| 107 | + ) |
| 108 | + default_scheduler.start() |
| 109 | + |
| 110 | +Interval and cron jobs coexist in the same scheduler; ``job.is_cron`` |
| 111 | +tells them apart. GUI: **Scheduler** tab has cron/interval radio. |
| 112 | + |
| 113 | + |
| 114 | +Plugin loader |
| 115 | +============= |
| 116 | + |
| 117 | +A plugin file is any ``.py`` defining top-level callables whose names |
| 118 | +start with ``AC_``. Each one becomes a new executor command:: |
| 119 | + |
| 120 | + # my_plugins/greeting.py |
| 121 | + def AC_greet(args=None): |
| 122 | + return f"hello, {args['name']}" |
| 123 | + |
| 124 | +:: |
| 125 | + |
| 126 | + from je_auto_control import ( |
| 127 | + load_plugin_directory, register_plugin_commands, |
| 128 | + ) |
| 129 | + commands = load_plugin_directory("my_plugins/") |
| 130 | + register_plugin_commands(commands) |
| 131 | + |
| 132 | + # Now usable from JSON: |
| 133 | + # [["AC_greet", {"name": "world"}]] |
| 134 | + |
| 135 | +GUI: **Plugins** tab (browse directory, one-click register). |
| 136 | + |
| 137 | +.. warning:: |
| 138 | + Plugin files execute arbitrary Python. Only load from directories |
| 139 | + under your own control. |
| 140 | + |
| 141 | + |
| 142 | +REST API server |
| 143 | +=============== |
| 144 | + |
| 145 | +A stdlib-only HTTP server that exposes the executor and scheduler:: |
| 146 | + |
| 147 | + from je_auto_control import start_rest_api_server |
| 148 | + server = start_rest_api_server(host="127.0.0.1", port=9939) |
| 149 | + |
| 150 | +Endpoints: |
| 151 | + |
| 152 | +- ``GET /health`` — liveness probe |
| 153 | +- ``GET /jobs`` — scheduler job list |
| 154 | +- ``POST /execute`` with body ``{"actions": [...]}`` — run actions |
| 155 | + |
| 156 | +GUI: **Socket Server** tab now has a separate REST section with its own |
| 157 | +host/port and a ``0.0.0.0`` opt-in. |
| 158 | + |
| 159 | +.. note:: |
| 160 | + Defaults to ``127.0.0.1`` per CLAUDE.md policy. Bind to ``0.0.0.0`` |
| 161 | + only when you have authenticated the network boundary. |
| 162 | + |
| 163 | + |
| 164 | +CLI runner |
| 165 | +========== |
| 166 | + |
| 167 | +A thin subcommand-based CLI over the headless APIs:: |
| 168 | + |
| 169 | + python -m je_auto_control.cli run script.json |
| 170 | + python -m je_auto_control.cli run script.json --var name=alice --dry-run |
| 171 | + python -m je_auto_control.cli list-jobs |
| 172 | + python -m je_auto_control.cli start-server --port 9938 |
| 173 | + python -m je_auto_control.cli start-rest --port 9939 |
| 174 | + |
| 175 | +``--var name=value`` is parsed as JSON when possible (so ``count=10`` |
| 176 | +becomes an int), otherwise treated as a string. |
| 177 | + |
| 178 | + |
| 179 | +Multi-language GUI (i18n) |
| 180 | +========================= |
| 181 | + |
| 182 | +Live language switching via the **Language** menu. Built-in packs: |
| 183 | + |
| 184 | +- English |
| 185 | +- Traditional Chinese (繁體中文) |
| 186 | +- Simplified Chinese (简体中文) |
| 187 | +- Japanese (日本語) |
| 188 | + |
| 189 | +Register additional languages at runtime:: |
| 190 | + |
| 191 | + from je_auto_control.gui.language_wrapper.multi_language_wrapper import ( |
| 192 | + language_wrapper, |
| 193 | + ) |
| 194 | + language_wrapper.register_language("French", {"menu_file": "Fichier", ...}) |
| 195 | + |
| 196 | +Missing keys fall through to the English default, so a feature ships |
| 197 | +with usable labels even before its translations land. |
| 198 | + |
| 199 | + |
| 200 | +Closable tabs + menu bar |
| 201 | +======================== |
| 202 | + |
| 203 | +The main window is now a ``QMainWindow`` with: |
| 204 | + |
| 205 | +- **File** → Open Script, Exit |
| 206 | +- **View → Tabs** → checkable entries for every tab (restore closed tabs) |
| 207 | +- **Tools** → Start hotkey daemon / scheduler / trigger engine |
| 208 | +- **Language** → select a registered language pack |
| 209 | +- **Help** → About |
| 210 | + |
| 211 | +Close any tab with its ✕ button; re-open it via *View → Tabs*. |
0 commit comments