Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

chore(windows): add a headless Windows 11 ARM test VM driven from the Mac

wquguru83580c2d39ac
diff --git a/windows/README.md b/windows/README.md
index a708977..0002a30 100644
--- a/windows/README.md
+++ b/windows/README.md
@@ -50,3 +50,21 @@ DOTNET_ROOT=~/.dotnet build/cli/cicada-cli roundtrip ~/Library/Application\ Supp
```
其余命令:`start`、`stop`、`view subtitles`、`capture on`、`show records`、`quit`。
6. 检查:日志里 `tap:` 那行是实际的录音格式,不应出现 `display affinity failed`;纪要窗不抢焦点(点它之后原来的窗口仍能打字);Win+Shift+S 截图和会议软件的屏幕共享里看不到它;打开“共享屏幕时让对方看到”后能看到,并显示“对方可见”;用浏览器放一段视频再 `start`,字幕跟得上。
+
+## 在 Mac 上自动测(QEMU 虚拟机)
+
+`vm/` 里是一台无界面的 Windows 11 ARM 测试机:QEMU + HVF,装机全自动(`autounattend.xml`),装好后用 SSH 驱动。
+
+```bash
+brew install qemu
+# 放进 ~/VMs/cicada-win11/:win11.iso(微软官网 ARM64 ISO)、virtio-win.iso、vm_key(ssh-keygen 生成)
+vm/run.sh # 第一次会自动装 Windows,约 30 分钟;之后几十秒开机
+scripts/build.sh && vm/deploy.sh
+vm/vmctl.sh g launch 'C:\cicada-test\Cicada-win-arm64\Cicada.exe' --dev
+vm/vmctl.sh ssh '& C:\cicada-test\Cicada-win-arm64\test\cicadactl.ps1 state'
+vm/vmctl.sh g play 'C:\cicada-test\Cicada-win-arm64\test\zh.wav' # 另一个进程放声音
+vm/vmctl.sh shot out.png # 屏幕本身(看得到纪要窗)
+vm/vmctl.sh g shot C:\x.png # Windows 里截图(屏幕共享看到的,不应有纪要窗)
+```
+
+`vmctl.sh g …` 调 `guest.ps1`:SSH 会话没有桌面,要桌面的事(启动、放声音、截图、点击、看前台窗口)都通过计划任务在登录的桌面里做。测不到的:真机 x64、蓝牙耳机切换、多显示器 DPI、会议软件的真实屏幕共享。
diff --git a/windows/vm/autounattend.xml b/windows/vm/autounattend.xml
new file mode 100644
index 0000000..91f7b12
--- /dev/null
+++ b/windows/vm/autounattend.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Unattended Windows 11 ARM64 for testing Cicada under QEMU: one local admin that logs on by
+ itself, no OOBE, hardware checks bypassed, virtio network driver, OpenSSH server for the host. -->
+<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
+ <settings pass="windowsPE">
+ <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <SetupUILanguage><UILanguage>zh-CN</UILanguage></SetupUILanguage>
+ <InputLocale>0804:00000804</InputLocale><SystemLocale>zh-CN</SystemLocale><UILanguage>zh-CN</UILanguage><UserLocale>zh-CN</UserLocale>
+ </component>
+ <component name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <DriverPaths>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="1"><Path>D:\NetKVM\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="2"><Path>E:\NetKVM\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="3"><Path>F:\NetKVM\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="4"><Path>G:\NetKVM\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="5"><Path>D:\viogpudo\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="6"><Path>E:\viogpudo\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="7"><Path>F:\viogpudo\w11\ARM64</Path></PathAndCredentials>
+ <PathAndCredentials wcm:action="add" wcm:keyValue="8"><Path>G:\viogpudo\w11\ARM64</Path></PathAndCredentials>
+ </DriverPaths>
+ </component>
+ <component name="Microsoft-Windows-Setup" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <RunSynchronous>
+ <RunSynchronousCommand wcm:action="add"><Order>1</Order><Path>reg add HKLM\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1 /f</Path></RunSynchronousCommand>
+ <RunSynchronousCommand wcm:action="add"><Order>2</Order><Path>reg add HKLM\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1 /f</Path></RunSynchronousCommand>
+ <RunSynchronousCommand wcm:action="add"><Order>3</Order><Path>reg add HKLM\SYSTEM\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 1 /f</Path></RunSynchronousCommand>
+ </RunSynchronous>
+ <DiskConfiguration>
+ <Disk wcm:action="add">
+ <DiskID>0</DiskID><WillWipeDisk>true</WillWipeDisk>
+ <CreatePartitions>
+ <CreatePartition wcm:action="add"><Order>1</Order><Type>EFI</Type><Size>300</Size></CreatePartition>
+ <CreatePartition wcm:action="add"><Order>2</Order><Type>MSR</Type><Size>16</Size></CreatePartition>
+ <CreatePartition wcm:action="add"><Order>3</Order><Type>Primary</Type><Extend>true</Extend></CreatePartition>
+ </CreatePartitions>
+ <ModifyPartitions>
+ <ModifyPartition wcm:action="add"><Order>1</Order><PartitionID>1</PartitionID><Format>FAT32</Format><Label>System</Label></ModifyPartition>
+ <ModifyPartition wcm:action="add"><Order>2</Order><PartitionID>3</PartitionID><Format>NTFS</Format><Label>Windows</Label><Letter>C</Letter></ModifyPartition>
+ </ModifyPartitions>
+ </Disk>
+ </DiskConfiguration>
+ <ImageInstall><OSImage>
+ <InstallFrom><MetaData wcm:action="add"><Key>/IMAGE/NAME</Key><Value>Windows 11 Pro</Value></MetaData></InstallFrom>
+ <InstallTo><DiskID>0</DiskID><PartitionID>3</PartitionID></InstallTo>
+ </OSImage></ImageInstall>
+ <UserData><AcceptEula>true</AcceptEula><ProductKey><Key>VK7JG-NPHTM-C97JM-9MPGT-3V66T</Key></ProductKey></UserData>
+ </component>
+ </settings>
+ <settings pass="specialize">
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <ComputerName>CICADA-TEST</ComputerName><TimeZone>China Standard Time</TimeZone>
+ </component>
+ </settings>
+ <settings pass="oobeSystem">
+ <component name="Microsoft-Windows-International-Core" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <InputLocale>0804:00000804</InputLocale><SystemLocale>zh-CN</SystemLocale><UILanguage>zh-CN</UILanguage><UserLocale>zh-CN</UserLocale>
+ </component>
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <OOBE>
+ <HideEULAPage>true</HideEULAPage><HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
+ <HideOnlineAccountScreens>true</HideOnlineAccountScreens><HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
+ <HideLocalAccountScreen>true</HideLocalAccountScreen><ProtectYourPC>3</ProtectYourPC>
+ </OOBE>
+ <UserAccounts><LocalAccounts><LocalAccount wcm:action="add">
+ <Name>tester</Name><Group>Administrators</Group><Password><Value>Cicada-test-1</Value><PlainText>true</PlainText></Password>
+ </LocalAccount></LocalAccounts></UserAccounts>
+ <AutoLogon><Enabled>true</Enabled><Username>tester</Username><Password><Value>Cicada-test-1</Value><PlainText>true</PlainText></Password><LogonCount>9999999</LogonCount></AutoLogon>
+ <FirstLogonCommands>
+ <SynchronousCommand wcm:action="add"><Order>1</Order><CommandLine>powershell -NoProfile -ExecutionPolicy Bypass -Command "foreach ($d in 'D','E','F','G','H') { if (Test-Path ${d}:\firstlogon.ps1) { &amp; ${d}:\firstlogon.ps1; break } }"</CommandLine></SynchronousCommand>
+ </FirstLogonCommands>
+ </component>
+ </settings>
+</unattend>
diff --git a/windows/vm/deploy.sh b/windows/vm/deploy.sh
new file mode 100755
index 0000000..b269b70
--- /dev/null
+++ b/windows/vm/deploy.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+# Quits Cicada in the test VM and copies in fresh builds (run scripts/build.sh first).
+set -euo pipefail
+here="$(cd "$(dirname "$0")" && pwd)"
+"$here/vmctl.sh" ssh 'Get-Process Cicada -ErrorAction SilentlyContinue | Stop-Process -Force; Start-Sleep 1; Remove-Item C:\cicada-test\Cicada-win-arm64, C:\cicada-test\Cicada-win-x64 -Recurse -Force -ErrorAction SilentlyContinue'
+for rid in win-arm64 win-x64; do "$here/vmctl.sh" put "$here/../build/Cicada-$rid" C:/cicada-test/; done
+"$here/vmctl.sh" put "$here/guest.ps1" C:/cicada-test/
+echo deployed
diff --git a/windows/vm/firstlogon.ps1 b/windows/vm/firstlogon.ps1
new file mode 100644
index 0000000..a82f0a2
--- /dev/null
+++ b/windows/vm/firstlogon.ps1
@@ -0,0 +1,23 @@
+# First logon: OpenSSH server (PowerShell shell, key auth for the host), no sleep or lock, then a marker.
+$ErrorActionPreference = 'Continue'
+Start-Transcript C:\firstlogon.log
+$src = Split-Path $MyInvocation.MyCommand.Path
+powercfg /change monitor-timeout-ac 0; powercfg /change standby-timeout-ac 0
+reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Personalization" /v NoLockScreen /t REG_DWORD /d 1 /f
+reg add "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 0 /f
+Set-NetConnectionProfile -NetworkCategory Private -ErrorAction SilentlyContinue
+# OpenSSH: the built-in capability first, else the zip on this disc.
+if (-not (Get-Service sshd -ErrorAction SilentlyContinue)) { Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 }
+if (-not (Get-Service sshd -ErrorAction SilentlyContinue) -and (Test-Path "$src\OpenSSH-ARM64.zip")) {
+ Expand-Archive "$src\OpenSSH-ARM64.zip" 'C:\Program Files' -Force
+ & 'C:\Program Files\OpenSSH-ARM64\install-sshd.ps1'
+}
+Set-Service sshd -StartupType Automatic; Start-Service sshd
+New-ItemProperty -Path HKLM:\SOFTWARE\OpenSSH -Name DefaultShell -Value 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -PropertyType String -Force
+New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Protocol TCP -LocalPort 22 -Action Allow -ErrorAction SilentlyContinue
+New-Item -ItemType Directory C:\ProgramData\ssh -Force | Out-Null
+Copy-Item "$src\authorized_keys" C:\ProgramData\ssh\administrators_authorized_keys -Force
+icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
+Restart-Service sshd
+Set-Content C:\firstlogon.done (Get-Date)
+Stop-Transcript
diff --git a/windows/vm/guest.ps1 b/windows/vm/guest.ps1
new file mode 100644
index 0000000..ead5176
--- /dev/null
+++ b/windows/vm/guest.ps1
@@ -0,0 +1,116 @@
+# Guest-side helpers, run over SSH. SSH sessions have no desktop, so anything that needs one
+# (launching Cicada, playing sound, screenshots, clicks, the foreground window) runs as a one-off
+# scheduled task in tester's logged-on session and writes its result to a file we read back.
+# guest.ps1 desk '<powershell>' # run in the desktop session, wait, print its output
+# guest.ps1 launch <exe> [args] # start a program on the desktop without waiting
+# guest.ps1 shot <out.png> # screenshot taken inside Windows (what screen sharing sees)
+# guest.ps1 click <x> <y> # left click at physical pixel x,y
+# guest.ps1 key <keys> # SendKeys to the foreground window, e.g. "hello{ENTER}"
+# guest.ps1 front # title and process of the foreground window
+# guest.ps1 windows # visible top-level windows with their bounds
+# guest.ps1 play <wav> # play a WAV from another process (as a meeting app would)
+param([Parameter(Position = 0)][string]$Verb, [Parameter(ValueFromRemainingArguments = $true)][string[]]$Rest)
+$ErrorActionPreference = 'Stop'
+$dir = 'C:\cicada-test\guest'; New-Item -ItemType Directory $dir -Force | Out-Null
+
+$native = @'
+using System; using System.Runtime.InteropServices; using System.Text;
+public static class W {
+ [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
+ [DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetWindowText(IntPtr h, StringBuilder s, int n);
+ [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);
+ [DllImport("user32.dll")] public static extern bool SetCursorPos(int x, int y);
+ [DllImport("user32.dll")] public static extern void mouse_event(uint f, int x, int y, uint d, UIntPtr e);
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
+ public delegate bool EnumProc(IntPtr h, IntPtr l);
+ [DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc p, IntPtr l);
+ [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h);
+ [StructLayout(LayoutKind.Sequential)] public struct RECT { public int L, T, R, B; }
+ [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);
+ [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr h, int i);
+ [DllImport("user32.dll")] public static extern bool GetWindowDisplayAffinity(IntPtr h, out uint a);
+}
+'@
+
+function Desk([string]$script, [int]$timeout = 60, [switch]$NoWait) {
+ $id = [guid]::NewGuid().ToString('N').Substring(0, 8)
+ $ps1 = "$dir\$id.ps1"; $out = "$dir\$id.out"; $done = "$dir\$id.done"
+ # The script redirects its own output, so the task line needs no quotes; conhost --headless keeps
+ # a console window from flashing up and taking the foreground.
+ @"
+`$ErrorActionPreference='Continue'
+& {
+Add-Type -TypeDefinition @'
+$native
+'@
+[W]::SetProcessDPIAware() | Out-Null
+try {
+$script
+} catch { "error: `$_" }
+} *> '$out'
+Set-Content '$done' 1
+"@ | Set-Content $ps1 -Encoding UTF8
+ $cmd = "conhost.exe --headless powershell.exe -NoProfile -ExecutionPolicy Bypass -File $ps1"
+ schtasks /create /tn "cicada-$id" /tr $cmd /sc once /st 23:59 /it /ru $env:USERNAME /f | Out-Null
+ schtasks /run /tn "cicada-$id" | Out-Null
+ if ($NoWait) { Start-Sleep 1; schtasks /delete /tn "cicada-$id" /f | Out-Null; return }
+ $t = 0; while (-not (Test-Path $done) -and $t -lt $timeout * 4) { Start-Sleep -Milliseconds 250; $t++ }
+ schtasks /delete /tn "cicada-$id" /f | Out-Null
+ if (Test-Path $out) { Get-Content $out -Encoding UTF8 }
+ if (-not (Test-Path $done)) { "error: timed out" }
+}
+
+switch ($Verb) {
+ 'desk' { Desk ($Rest -join ' ') }
+ 'launch' {
+ $exe = $Rest[0]; $args2 = ($Rest | Select-Object -Skip 1) -join ' '
+ $argPart = if ($args2) { "-ArgumentList '$args2'" } else { '' }
+ Desk "Start-Process '$exe' $argPart -WorkingDirectory (Split-Path '$exe')" -NoWait
+ }
+ 'shot' {
+ $png = $Rest[0]
+ Desk @"
+Add-Type -AssemblyName System.Windows.Forms, System.Drawing
+`$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
+`$bmp = New-Object System.Drawing.Bitmap `$b.Width, `$b.Height
+`$g = [System.Drawing.Graphics]::FromImage(`$bmp); `$g.CopyFromScreen(`$b.Left, `$b.Top, 0, 0, `$bmp.Size)
+`$bmp.Save('$png', [System.Drawing.Imaging.ImageFormat]::Png); "saved `$(`$b.Width)x`$(`$b.Height)"
+"@
+ }
+ 'click' {
+ Desk "[W]::SetCursorPos($($Rest[0]), $($Rest[1])) | Out-Null; Start-Sleep -Milliseconds 100; [W]::mouse_event(2,0,0,0,[UIntPtr]::Zero); Start-Sleep -Milliseconds 60; [W]::mouse_event(4,0,0,0,[UIntPtr]::Zero); 'clicked'"
+ }
+ 'key' {
+ $k = ($Rest -join ' ').Replace("'", "''")
+ Desk "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('$k'); 'sent'"
+ }
+ 'front' {
+ Desk @'
+$h = [W]::GetForegroundWindow(); $s = New-Object System.Text.StringBuilder 256; [W]::GetWindowText($h, $s, 256) | Out-Null
+$p = 0; [W]::GetWindowThreadProcessId($h, [ref]$p) | Out-Null
+"$((Get-Process -Id $p).ProcessName) | $($s.ToString())"
+'@
+ }
+ 'windows' {
+ Desk @'
+$list = New-Object System.Collections.ArrayList
+[W]::EnumWindows({ param($h, $l)
+ if ([W]::IsWindowVisible($h)) {
+ $s = New-Object System.Text.StringBuilder 256; [W]::GetWindowText($h, $s, 256) | Out-Null
+ $p = 0; [W]::GetWindowThreadProcessId($h, [ref]$p) | Out-Null
+ $name = (Get-Process -Id $p -ErrorAction SilentlyContinue).ProcessName
+ if ($name -match 'Cicada|notepad|powershell') {
+ $r = New-Object W+RECT; [W]::GetWindowRect($h, [ref]$r) | Out-Null
+ $a = 0; [W]::GetWindowDisplayAffinity($h, [ref]$a) | Out-Null
+ $ex = [W]::GetWindowLong($h, -20)
+ [void]$list.Add(('{0} | {1} | {2},{3} {4}x{5} | exstyle=0x{6:X} affinity={7}' -f $name, $s, $r.L, $r.T, ($r.R - $r.L), ($r.B - $r.T), $ex, $a))
+ }
+ }; $true }, [IntPtr]::Zero) | Out-Null
+$list
+'@
+ }
+ 'play' {
+ Desk "(New-Object System.Media.SoundPlayer '$($Rest[0])').PlaySync(); 'played'" -timeout 300
+ }
+ default { "usage: guest.ps1 desk|launch|shot|click|key|front|windows|play" }
+}
diff --git a/windows/vm/run.sh b/windows/vm/run.sh
new file mode 100755
index 0000000..633828a
--- /dev/null
+++ b/windows/vm/run.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Runs the Windows 11 ARM64 test VM under QEMU (HVF), headless: VNC on :1, the QEMU monitor on
+# $VM/monitor.sock, SSH on localhost:2222. First run (no disk yet) installs Windows unattended.
+# VM=~/VMs/cicada-win11 windows/vm/run.sh # needs win11.iso, virtio-win.iso, vm_key in $VM
+set -euo pipefail
+here="$(cd "$(dirname "$0")" && pwd)"
+VM="${VM:-$HOME/VMs/cicada-win11}"
+cd "$VM"
+share=/opt/homebrew/share/qemu
+
+install=()
+if [ ! -f disk.qcow2 ]; then
+ qemu-img create -f qcow2 disk.qcow2 64G >/dev/null
+ cp "$share/edk2-arm-vars.fd" vars.fd
+ # The answer file and first-logon script on their own disc, with the host's SSH key and the
+ # OpenSSH zip in case the built-in capability can't be downloaded.
+ rm -rf seed && mkdir seed
+ cp "$here/autounattend.xml" "$here/firstlogon.ps1" seed/
+ cp vm_key.pub seed/authorized_keys
+ [ -f OpenSSH-ARM64.zip ] && cp OpenSSH-ARM64.zip seed/
+ rm -f seed.iso && hdiutil makehybrid -quiet -iso -joliet -o seed.iso seed
+ install=(-drive file=win11.iso,media=cdrom,if=none,id=cd0,readonly=on -device usb-storage,drive=cd0,bootindex=0
+ -drive file=seed.iso,media=cdrom,if=none,id=cd1,readonly=on -device usb-storage,drive=cd1)
+fi
+
+# No TPM: HVF refuses tpm-tis-device (HV_BAD_ARGUMENT); the answer file bypasses Windows 11's check.
+qemu-system-aarch64 \
+ -name cicada-win11 -machine virt,highmem=on -accel hvf -cpu host -smp 4 -m 8G -device qemu-xhci \
+ -drive if=pflash,format=raw,readonly=on,file="$share/edk2-aarch64-code.fd" \
+ -drive if=pflash,format=raw,file=vars.fd \
+ -device nvme,drive=hd,serial=cicada,bootindex=1 -drive file=disk.qcow2,if=none,id=hd,discard=unmap \
+ ${install[@]+"${install[@]}"} \
+ -drive file=virtio-win.iso,media=cdrom,if=none,id=cd2,readonly=on -device usb-storage,drive=cd2 \
+ -device virtio-gpu-pci -device usb-kbd -device usb-tablet \
+ -audiodev none,id=snd -device usb-audio,audiodev=snd \
+ -nic user,model=virtio-net-pci,hostfwd=tcp:127.0.0.1:2222-:22 \
+ -vnc 127.0.0.1:1 -monitor unix:"$VM/monitor.sock",server,nowait -daemonize -pidfile "$VM/qemu.pid" </dev/null >/dev/null 2>"$VM/qemu.log" || { cat "$VM/qemu.log" >&2; exit 1; }
diff --git a/windows/vm/vmctl.sh b/windows/vm/vmctl.sh
new file mode 100755
index 0000000..d9f9828
--- /dev/null
+++ b/windows/vm/vmctl.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Host-side helpers for the test VM.
+# vmctl.sh shot <out.png> # screenshot of the VM's screen (what a viewer of the display sees)
+# vmctl.sh mon <command…> # one QEMU monitor command (sendkey ret, mouse_move…, system_powerdown)
+# vmctl.sh ssh <powershell…> # run PowerShell in the VM over SSH
+# vmctl.sh put <local> <remote> # copy into the VM
+# vmctl.sh run <local.ps1> # run a script in the VM's desktop session and print its output
+# vmctl.sh g <verb> <args…> # guest.ps1 in the VM (desk, launch, shot, click, key, front, windows, play)
+set -euo pipefail
+VM="${VM:-$HOME/VMs/cicada-win11}"
+common=(-i "$VM/vm_key" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o ConnectTimeout=5)
+mon() { printf '%s\n' "$*" | nc -U -w 2 "$VM/monitor.sock" >/dev/null; }
+case "$1" in
+ shot)
+ tmp="$VM/shot.ppm"; rm -f "$tmp"; mon "screendump $tmp"
+ for _ in 1 2 3 4 5 6 7 8 9 10; do [ -s "$tmp" ] && break; sleep 0.3; done
+ sleep 0.3; sips -s format png "$tmp" --out "$2" >/dev/null ;;
+ mon) shift; mon "$*" ;;
+ ssh) shift; ssh "${common[@]}" -p 2222 [email protected] "[Console]::OutputEncoding = [Text.Encoding]::UTF8; $*" ;;
+ g) shift; "$0" ssh "& C:\\cicada-test\\guest.ps1 $*" ;; # a guest.ps1 verb, e.g. g front
+ run) # a local .ps1 in the VM's desktop session: no quoting through ssh and schtasks
+ "$0" put "$2" C:/cicada-test/run.ps1 && "$0" g desk "'& C:\\cicada-test\\run.ps1'" ;;
+ put) scp -r "${common[@]}" -P 2222 "$2" "[email protected]:$3" ;;
+ *) echo "usage: vmctl.sh shot|mon|ssh|put" >&2; exit 2 ;;
+esac