main
John Lauer Corrected Astra ESC routing: native zero-open result, full accounting and voiceover handoff a80479d 23d ago
from bridge import *
import base64
script=r'''Add-Type -TypeDefinition @"
using System; using System.Runtime.InteropServices;
public static class AstraDisplayLease {
 [DllImport("kernel32.dll")] private static extern uint SetThreadExecutionState(uint flags);
 public static uint Hold() { return SetThreadExecutionState(0x80000003); }
 public static uint Release() { return SetThreadExecutionState(0x80000000); }
}
"@
if ([AstraDisplayLease]::Hold() -eq 0) { throw "Display lease failed" }
$leaseEvent = New-Object System.Threading.EventWaitHandle($false, [System.Threading.EventResetMode]::ManualReset, 'Local\AstraEscRoutingDisplayLease')
try { $null = $leaseEvent.WaitOne(1200000) } finally { $null = [AstraDisplayLease]::Release(); $leaseEvent.Dispose() }
'''
r=call('launch_process',dict(path='C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',args=['-NoProfile','-NonInteractive','-EncodedCommand',base64.b64encode(script.encode('utf-16le')).decode()],window='hidden',reason='Keep the test display awake for the corrected routing recording without changing its power settings; release automatically after 20 minutes or at cleanup'))
(D/'evidence/display-lease.json').write_text(json.dumps(r));print(r)