Skip to content

Commit 97159f0

Browse files
committed
re-record demo with forced English IME (clean code on screen); smaller gif
1 parent 0448c85 commit 97159f0

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎docs/demo_real.gif‎

-629 KB
Loading

‎docs/demo_real.mp4‎

-94.5 KB
Binary file not shown.

‎scripts/record_demo.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ def record_loop(stop_event: threading.Event) -> None:
110110
writer.close()
111111

112112

113+
def force_english_input() -> None:
114+
"""Make sure the active keyboard layout is plain English (US) so every
115+
keystroke lands literally instead of through an IME."""
116+
import ctypes, ctypes.wintypes
117+
user32 = ctypes.windll.user32
118+
hkl = user32.LoadKeyboardLayoutW("00000409", 1) # KLF_ACTIVATE
119+
if not hkl:
120+
return
121+
user32.ActivateKeyboardLayout(hkl, 0)
122+
# also tell every top-level window to switch to it (esp. notepad)
123+
WM_INPUTLANGCHANGEREQUEST = 0x0050
124+
hwnds = []
125+
@ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.wintypes.HWND, ctypes.wintypes.LPARAM)
126+
def cb(hwnd, lparam):
127+
if user32.IsWindowVisible(hwnd):
128+
user32.PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST, 0, hkl)
129+
return True
130+
user32.EnumWindows(cb, 0)
131+
132+
113133
def type_code(seconds: float) -> None:
114134
"""Type real keystrokes (only ASCII) with human-ish rhythm."""
115135
end = time.time() + seconds
@@ -170,6 +190,8 @@ def main() -> None:
170190
time.sleep(0.2)
171191

172192
print("[phase] typing (40s)", flush=True)
193+
force_english_input()
194+
time.sleep(0.5)
173195
type_code(40)
174196

175197
print("[phase] cpu stress on (95s: 35s typing + 60s stopped)", flush=True)

0 commit comments

Comments
 (0)