Skip to content

Commit 03e2fe7

Browse files
abrichrclaude
andcommitted
fix: detect and dismiss Windows lock screen before each task
Add _dismiss_lock_screen() to run_dc_eval.py that checks for LogonUI.exe process and types the password to unlock if the screen is locked. Called from ensure_waa_ready() after each successful probe. This prevents eval failures when the Windows VM has been idle and the lock screen has engaged between tasks or between sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01ef338 commit 03e2fe7

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

scripts/run_dc_eval.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,49 @@ def _start_tunnel(vm_user: str, vm_ip: str) -> bool:
6060
return result.returncode == 0
6161

6262

63+
def _dismiss_lock_screen(server: str) -> bool:
64+
"""Detect and dismiss Windows lock screen if present.
65+
66+
Checks for LogonUI.exe process (Windows lock screen). If found,
67+
types the password ("admin") and presses Enter to unlock.
68+
69+
Returns True if lock screen was dismissed or wasn't present.
70+
"""
71+
try:
72+
# Check for LogonUI.exe process
73+
resp = requests.post(
74+
f"{server}/execute",
75+
json={"command": 'powershell -Command "(Get-Process LogonUI -ErrorAction SilentlyContinue) -ne $null"'},
76+
timeout=10,
77+
)
78+
if not resp.ok:
79+
return True # Can't check, assume OK
80+
81+
output = resp.json().get("output", "").strip()
82+
if output != "True":
83+
return True # Not locked
84+
85+
print(" Lock screen detected (LogonUI.exe running), dismissing...")
86+
87+
# Type password and press Enter via pyautogui
88+
resp = requests.post(
89+
f"{server}/execute",
90+
json={"command": 'python -c "import pyautogui, time; pyautogui.press(\'enter\'); time.sleep(1); pyautogui.typewrite(\'admin\', interval=0.05); time.sleep(0.5); pyautogui.press(\'enter\')"'},
91+
timeout=15,
92+
)
93+
if resp.ok:
94+
print(" Lock screen dismissed, waiting for desktop...")
95+
time.sleep(5) # Wait for desktop to load
96+
return True
97+
else:
98+
print(f" Failed to dismiss lock screen: {resp.text}")
99+
return False
100+
101+
except Exception as e:
102+
print(f" Lock screen check error: {e}")
103+
return True # Don't block on check failures
104+
105+
63106
def _probe(server: str, timeout: int = 10) -> bool:
64107
try:
65108
resp = requests.get(f"{server}/probe", timeout=timeout)
@@ -122,6 +165,7 @@ def ensure_waa_ready(
122165
"""
123166
# Step 1: Quick probe
124167
if _probe(server) and (evaluate_url is None or _probe(evaluate_url)):
168+
_dismiss_lock_screen(server)
125169
return True
126170

127171
# Step 2: Reconnect tunnel
@@ -132,6 +176,7 @@ def ensure_waa_ready(
132176
time.sleep(3)
133177
if _probe(server) and (evaluate_url is None or _probe(evaluate_url)):
134178
print(" Tunnel reconnected, WAA ready!")
179+
_dismiss_lock_screen(server)
135180
return True
136181

137182
# Step 3: Tunnel up but WAA not responding → container restart
@@ -157,6 +202,7 @@ def ensure_waa_ready(
157202
last_print = elapsed
158203
if _probe(server, timeout=10) and (evaluate_url is None or _probe(evaluate_url, timeout=10)):
159204
print(f" WAA ready after {elapsed}s!")
205+
_dismiss_lock_screen(server)
160206
return True
161207
time.sleep(10)
162208

0 commit comments

Comments
 (0)