param( [Parameter(Mandatory = $true)] [ValidateSet('MicrosoftPinyin', 'Sogou')] [string]$ImeName, [switch]$InputLanguageOnly ) $ErrorActionPreference = 'Stop' $root = Split-Path -Parent $PSScriptRoot $msbuild = if ($env:STELLARX_MSBUILD) { $env:STELLARX_MSBUILD } else { 'D:\vs2022\MSBuild\Current\Bin\MSBuild.exe' } $project = Join-Path $root 'tests\StellarX.UiFixture.vcxproj' $fixture = Join-Path $root 'build\x64\Debug\StellarX.UiFixture.exe' if (-not (Test-Path -LiteralPath $msbuild)) { throw "MSBuild not found: $msbuild" } $pathKeyCount = @( [Environment]::GetEnvironmentVariables([EnvironmentVariableTarget]::Process).Keys | Where-Object { [string]$_ -ieq 'Path' } ).Count if ($pathKeyCount -gt 1) { # Codex 等宿主可能注入同时存在的 PATH/Path;MSBuild 启动 CL 时会因重复键失败。 # cmd 的 set 精确删除第一份 PATH 后仍保留 Path,只影响这个构建子进程。 $buildCommand = 'set "PATH=" & "' + $msbuild + '" "' + $project + '" /m /t:Build /p:Configuration=Debug /p:Platform=x64 /p:StellarXInputProbe=true /v:minimal' & $env:ComSpec /d /c $buildCommand } else { & $msbuild $project /m /t:Build /p:Configuration=Debug /p:Platform=x64 /p:StellarXInputProbe=true /v:minimal } if ($LASTEXITCODE -ne 0) { throw 'Input probe fixture build failed' } $stamp = Get-Date -Format 'yyyyMMdd-HHmmss-fff' $runDir = Join-Path $root "TestResults\InputProbe\manual-$stamp-$ImeName" $fixtureDir = Join-Path $runDir 'fixture' New-Item -ItemType Directory -Force -Path $runDir | Out-Null New-Item -ItemType Directory -Force -Path $fixtureDir | Out-Null Write-Host "Manual IME probe: $ImeName" if ($InputLanguageOnly) { Write-Host 'Input-language-only checklist:' Write-Host ' 1. Click the EasyX window so it owns keyboard focus' Write-Host ' 2. Use Win+Space to select a different language/keyboard layout, for example English (US)' Write-Host ' Switching only between two Chinese IMEs stays in the same HKL and may not emit request/change' Write-Host ' 3. Type A, then use Win+Space to return to the original input method/layout' } else { Write-Host 'Use only these non-sensitive strings:' Write-Host ' 1. zhongwentest -> choose a Chinese candidate and commit' Write-Host ' 2. haha -> commit the same Chinese character twice' Write-Host ' 3. ceshi -> press Escape before committing' Write-Host ' 4. Type a candidate sequence and select it with a number key' Write-Host ' 5. Use Win+Space to select a different language/keyboard layout (for example English (US)), then type A' } Write-Host 'Close the EasyX window when finished. The script will then print a privacy-safe summary.' $launchCommand = 'set "STELLARX_INPUT_PROBE=1" & set "STELLARX_INPUT_PROBE_DIR=' + $runDir + '" & "' + $fixture + '" input-probe "' + $fixtureDir + '"' & $env:ComSpec /d /c $launchCommand $exitCode = $LASTEXITCODE $summary = & (Join-Path $PSScriptRoot 'analyze-input-probe.ps1') -Path $runDir # EX_SHOWCONSOLE 下由脚本托管的 EasyX 进程在原生标题栏关闭时,部分控制台宿主会把 # 正常窗口关闭映射为 STATUS_CONTROL_C_EXIT。必须先验证探测日志完整性和关闭证据, # 不能无条件忽略这个非零退出码,否则真实崩溃也可能被误报为成功。 $controlCExit = -1073741510 # 0xC000013A $validNativeClose = $summary.sequenceStrict -and $summary.closeObserved -and $summary.textRawWParamLeaks -eq 0 $summary | Format-List Write-Host "Result directory: $runDir" if ($exitCode -ne 0 -and -not ($exitCode -eq $controlCExit -and $validNativeClose)) { throw "Input probe fixture exited with code $exitCode" } if ($exitCode -eq $controlCExit) { Write-Host 'Fixture exit code: 0xC000013A (accepted after validating native-close probe records).' }