import subprocess,pathlib,time
root=pathlib.Path(__file__).parent
# Start on the queue sheet, with two synthetic image-bearing messages queued.
def run(*args):
    r=subprocess.run(['agent-device',*args,'--session','queued-preview'],capture_output=True,text=True)
    with (root/'native-head-actions.log').open('a') as f:f.write(' '.join(args)+'\n'+r.stdout+r.stderr+'\n')
    if r.returncode:raise RuntimeError(r.stderr)
run('record','start',str(root/'ios-head-complete.mp4'))
run('press','55','438','--settle')
time.sleep(2)
run('press','364','84','--settle')
time.sleep(1)
run('press','text="img1.png"','--settle')
time.sleep(2)
run('screenshot',str(root/'ios-head-image1.png'))
run('press','38','84','--settle')
run('press','55','486','--settle')
time.sleep(2)
run('press','364','84','--settle')
time.sleep(1)
run('press','text="other1.png"','--settle')
time.sleep(2)
run('press','38','84','--settle')
time.sleep(1)
run('record','stop')
