|
9 | 9 | from contextlib import contextmanager
|
10 | 10 | from pathlib import Path
|
11 | 11 |
|
12 |
| -import keyboard |
13 | 12 | import pytest
|
14 | 13 | from pyvirtualdisplay.smartdisplay import SmartDisplay
|
15 | 14 |
|
| 15 | +if sys.platform == "win32": |
| 16 | + from ahk import AHK |
| 17 | + |
16 | 18 | logger = logging.getLogger(__name__)
|
17 | 19 |
|
18 | 20 |
|
@@ -157,12 +159,13 @@ def run_process_capture_logs(command, cwd, name="", process_holder=None) -> None
|
157 | 159 |
|
158 | 160 | def run_typing_process(workdir, text: str) -> None:
|
159 | 161 | if sys.platform == "win32":
|
160 |
| - #with open(workdir / "type.ahk", "w", encoding="utf-8") as f: |
161 |
| - # f.write("SetKeyDelay 400, 100\n") # 400ms between keys, 100ms between down/up. |
162 |
| - # f.write(f"SendEvent \"{text}\"\n") |
163 |
| - # f.write("exit") |
164 |
| - #result = subprocess.run(["AutoHotkey.exe", "/ErrorStdOut", "type.ahk"], cwd=workdir) |
165 |
| - keyboard.write(text, delay=0.4) |
| 162 | + # with open(workdir / "type.ahk", "w", encoding="utf-8") as f: |
| 163 | + # f.write("SetKeyDelay 400, 100\n") # 400ms between keys, 100ms between down/up. |
| 164 | + # f.write(f"SendEvent \"{text}\"\n") |
| 165 | + # f.write("exit") |
| 166 | + # result = subprocess.run(["AutoHotkey.exe", "/ErrorStdOut", "type.ahk"], cwd=workdir) |
| 167 | + ahk = AHK() |
| 168 | + ahk.type(text); |
166 | 169 | else:
|
167 | 170 | result = subprocess.run(["xdotool", "type", "--delay", "400", text])
|
168 | 171 | logger.info(f"stdout: {result.stdout}")
|
|
0 commit comments