Macro Recorder On Hax -
class Recorder static var events: Array<MacroEvent> = []; static var startTime: Int; public static function start():Void startTime = haxe.Timer.stamp() * 1000; InputHook.onMouseMove = (x, y) -> var now = (haxe.Timer.stamp() * 1000) - startTime; events.push(MouseMove(x, y, now)); ; // ... similar for keys/buttons
| Target | Capture Accuracy | Replay Jitter (avg) | Limitations | |------------|----------------|---------------------|---------------------------------| | Windows 11 | ±2 ms | ±4 ms | Needs admin for global hooks | | macOS 14 | ±3 ms | ±5 ms | Accessibility permission req. | | Linux (X11)| ±5 ms | ±7 ms | X11 record extension required | | Web (JS) | Not global | N/A | Only within canvas/iframe | macro recorder on hax
// Macro that reads a JSON macro file and generates a function static macro function embedMacro(path:String):Expr var json = sys.io.File.getContent(path); var events:Array<MacroEvent> = haxe.Json.parse(json); var exprBlocks = []; for (e in events) exprBlocks.push(macro simulateEvent($ve)); exprBlocks.push(macro haxe.Timer.delay(..., $ve.timestamp)); // simplified return macro $bexprBlocks; We tested the macro recorder on three platforms:
function replay(events:Array<MacroEvent>, speed:Float = 1.0):Void var i = 0; var startTime = haxe.Timer.stamp() * 1000; var timer = new haxe.Timer(1); // 1ms resolution timer.run = function() if (i >= events.length) timer.stop(); return; var now = (haxe.Timer.stamp() * 1000) - startTime; var targetTime = events[i].timestamp / speed; if (now >= targetTime) simulateEvent(events[i]); i++; ; class Recorder static var events: Array<
This generates a replay function with zero runtime parsing overhead. We tested the macro recorder on three platforms: