修复复核发现的问题: 坐标缩放、升级/同步判定、看门狗诊断、卡死检测
- scripts/lc_ui.py: 脚本坐标按 1600x900 书写, OCR 结果与点击/拖动按实际客户区换算; 去掉写死的 D:\lc-mcp 路径 - levelup.py: 升级以详情页等级/经验条变化判定成功; 同步先判断弹窗是否仍在, 无过场时不再多按 ESC、不再盲点取消 - auto_cycle.py: task_status 连续报 stall 即停任务; exit 0 但有 errors 判失败 - tasks.py: 运行中日志尾部"配队人数OCR得到"刷屏时返回 stall 字段 - keep_display.ps1: tscon 改用 -EncodedCommand 并记录退出码; 会话号自动取游戏所在会话 - 更正 10-05 README 选队结论、summary 卡死①统计、PITFALLS 坑 13 根因 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+26
-11
@@ -9,9 +9,13 @@
|
|||||||
#
|
#
|
||||||
# tscon 需要 SeTcbPrivilege, 普通令牌拿不到, 所以用 -Verb RunAs 提权。
|
# tscon 需要 SeTcbPrivilege, 普通令牌拿不到, 所以用 -Verb RunAs 提权。
|
||||||
# 本机 ConsentPromptBehaviorAdmin=0(从不通知), 提权静默通过, 不会弹框。
|
# 本机 ConsentPromptBehaviorAdmin=0(从不通知), 提权静默通过, 不会弹框。
|
||||||
|
#
|
||||||
|
# 会话号默认取游戏进程所在会话, 找不到游戏时取本脚本所在会话(计划任务以
|
||||||
|
# 登录用户身份运行, 与桌面同一会话)。重启或重新登录后会话号会变, 不要写死。
|
||||||
|
|
||||||
param(
|
param(
|
||||||
[int]$SessionId = 2,
|
[int]$SessionId = -1,
|
||||||
|
[string]$Python = "",
|
||||||
[string]$LogPath = "$env:USERPROFILE\lc_mcp\keep_display.log",
|
[string]$LogPath = "$env:USERPROFILE\lc_mcp\keep_display.log",
|
||||||
[switch]$Verbose,
|
[switch]$Verbose,
|
||||||
[switch]$ForceDisc
|
[switch]$ForceDisc
|
||||||
@@ -26,7 +30,11 @@ function Write-Log([string]$msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 会话状态: 用 WTS API (qwinsta 在计划任务上下文里拿不到输出)
|
# 会话状态: 用 WTS API (qwinsta 在计划任务上下文里拿不到输出)
|
||||||
$py = 'D:\lc-mcp\vendor\aalc\.venv\Scripts\python.exe'
|
$py = if ($Python) { $Python } else { Join-Path $PSScriptRoot '..\vendor\aalc\.venv\Scripts\python.exe' }
|
||||||
|
if ($SessionId -lt 0) {
|
||||||
|
$game = Get-Process -Name LimbusCompany -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||||
|
$SessionId = if ($game) { $game.SessionId } else { (Get-Process -Id $PID).SessionId }
|
||||||
|
}
|
||||||
$statePy = Join-Path $PSScriptRoot 'session_state.py'
|
$statePy = Join-Path $PSScriptRoot 'session_state.py'
|
||||||
if (-not (Test-Path $py) -or -not (Test-Path $statePy)) {
|
if (-not (Test-Path $py) -or -not (Test-Path $statePy)) {
|
||||||
Write-Log "missing python ($py) or session_state.py ($statePy); abort"
|
Write-Log "missing python ($py) or session_state.py ($statePy); abort"
|
||||||
@@ -39,30 +47,37 @@ if ($state -notin @('Active', 'Connected', 'Disc', 'Idle')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ForceDisc) {
|
if ($ForceDisc) {
|
||||||
$state = 'Disc'
|
|
||||||
Write-Log "ForceDisc: skipping state check (real state was '$state')"
|
Write-Log "ForceDisc: skipping state check (real state was '$state')"
|
||||||
|
$state = 'Disc'
|
||||||
} elseif ($state -ne 'Disc') {
|
} elseif ($state -ne 'Disc') {
|
||||||
if ($Verbose) { Write-Log "session $SessionId is $state; nothing to do" }
|
if ($Verbose) { Write-Log "session $SessionId is $state; nothing to do" }
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Log "session $SessionId is Disc -> re-attaching to console via elevated tscon"
|
Write-Log "session $SessionId is Disc -> re-attaching to console via elevated tscon"
|
||||||
$out = Join-Path $env:TEMP 'lc_keep_display_tscon.txt'
|
$out = Join-Path (Split-Path -Parent $LogPath) 'tscon_last.txt'
|
||||||
Remove-Item $out -ErrorAction SilentlyContinue
|
Remove-Item $out -ErrorAction SilentlyContinue
|
||||||
# 显式记录退出码: 只看有没有输出文件分不清"成功但无输出"和"根本没跑"
|
# 之前的版本把命令拼成 -Command 字符串交给 Start-Process, 10-05 的 41 次失败
|
||||||
$inner = "tscon $SessionId /dest:console > `"$out`" 2>&1; Add-Content `"$out`" ('EXIT=' + `$LASTEXITCODE)"
|
# 全部只留下 "(no output file)", 连 tscon 有没有跑都看不出(多半是引号在
|
||||||
|
# 命令行拼接时被吃掉, 重定向没生效)。改用 -EncodedCommand 原样传递,
|
||||||
|
# 并用 -PassThru 拿提权进程的退出码(= tscon 的退出码)。
|
||||||
|
# 32 位宿主里 System32 会被重定向到 SysWOW64, 那里没有 tscon.exe, 用 Sysnative 绕过。
|
||||||
|
$sysDir = if (Test-Path "$env:SystemRoot\Sysnative") { "$env:SystemRoot\Sysnative" } else { "$env:SystemRoot\System32" }
|
||||||
|
$inner = "& '$sysDir\tscon.exe' $SessionId /dest:console *> '$out'; exit `$LASTEXITCODE"
|
||||||
|
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($inner))
|
||||||
try {
|
try {
|
||||||
Start-Process -FilePath "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
|
$proc = Start-Process -FilePath "$sysDir\WindowsPowerShell\v1.0\powershell.exe" `
|
||||||
-ArgumentList @('-NoProfile', '-WindowStyle', 'Hidden', '-Command', $inner) `
|
-ArgumentList @('-NoProfile', '-NonInteractive', '-EncodedCommand', $encoded) `
|
||||||
-Verb RunAs -WindowStyle Hidden -Wait -ErrorAction Stop
|
-Verb RunAs -WindowStyle Hidden -Wait -PassThru -ErrorAction Stop
|
||||||
} catch {
|
} catch {
|
||||||
Write-Log "elevated tscon launch FAILED: $($_.Exception.Message)"
|
Write-Log "elevated tscon launch FAILED: $($_.Exception.Message)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Start-Sleep -Seconds 2
|
Start-Sleep -Seconds 2
|
||||||
$tsconOut = if (Test-Path $out) { ((Get-Content $out -Raw) -replace '\s+', ' ').Trim() } else { '(no output file)' }
|
$tsconOut = if (Test-Path $out) { ((Get-Content $out -Raw) -replace '\s+', ' ').Trim() } else { '' }
|
||||||
|
if (-not $tsconOut) { $tsconOut = '(no output)' }
|
||||||
$after = (& $py -X utf8 $statePy $SessionId 2>&1 | Out-String).Trim()
|
$after = (& $py -X utf8 $statePy $SessionId 2>&1 | Out-String).Trim()
|
||||||
Write-Log "tscon said: $tsconOut | session $SessionId now: $after"
|
Write-Log "tscon exit=$($proc.ExitCode) said: $tsconOut | session $SessionId now: $after"
|
||||||
|
|
||||||
# 渲染自检: BitBlt 屏幕 DC 成功 = 桌面在出图
|
# 渲染自检: BitBlt 屏幕 DC 成功 = 桌面在出图
|
||||||
$renderPy = Join-Path $PSScriptRoot 'render_check.py'
|
$renderPy = Join-Path $PSScriptRoot 'render_check.py'
|
||||||
|
|||||||
Reference in New Issue
Block a user