AutoHotkey Migration: Runtime, Timers, And State
Mapping AutoHotkey Sleep, SetTimer, and variables to EyeAuras script runtime and state APIs.
AutoHotkey Migration: Runtime, Timers, And State
Use this page for Sleep, SetTimer, ordinary variables, globals, built-in
variables, and shared state.
Quick Map
| AutoHotkey Need | AHK APIs | EyeAuras Route | First C# Shape | Judgment | Notes |
|---|---|---|---|---|---|
| Sleep or repeat later | Sleep, SetTimer | Script Sleep(...), loops, services, observables | Sleep(250); or run a cancellation-aware loop | Sleep is good; SetTimer needs redesign. | EyeAuras script Sleep(...) is cancellation-aware and can finish early when the script stops. Aura Tree timer actions/triggers are configurable components, not lightweight script API equivalents. |
| Store script state | Variables, built-in variables, globals | C# locals, fields, objects; ScriptVariable<T> only for shared/persistent state | var count = 0; or int Count { get; set; } | Better for normal in-script state; use script variables only when sharing is needed. | ScriptVariable<T> / IVariablesScriptingApi are for state shared across launches, between scripts, or with EyeAuras infrastructure outside the script. |
Sleep
AutoHotkey v2:
Sleep 250
EyeAuras script:
Sleep(250);
Recommendation: Good shape. EyeAuras Sleep(...) is cancellation-aware,
which is usually better for scripts that may be stopped by the user.
Ordinary State
AutoHotkey v2:
count := 0
count += 1
EyeAuras script:
var count = 0;
count += 1;
Use normal C# locals, fields, and objects for ordinary in-script state. Use
ScriptVariable<T> / IVariablesScriptingApi only when the value must be
shared across launches, between scripts, or with EyeAuras infrastructure
outside the script.
Recommendation: Better than AHK for normal in-script state because it is typed and explicit. Shared/persistent variables need separate examples.
Verification Links
- AHK docs: Sleep, SetTimer, Variables and Expressions, Functions, Concepts.
- AHK source: script2.cpp, vars.cpp, var.cpp.
- EyeAuras docs: Scripting Runtime, IVariablesScriptingApi.
- EyeAuras source: AuraScriptSandbox.cs, AuraScriptRunner.cs, IVariablesScriptingApi.cs, ScriptVariable.cs.