|
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 | + ahk = AHK() |
| 18 | + |
16 | 19 | logger = logging.getLogger(__name__)
|
17 | 20 |
|
18 | 21 |
|
@@ -157,17 +160,17 @@ def run_process_capture_logs(command, cwd, name="", process_holder=None) -> None
|
157 | 160 |
|
158 | 161 | def run_typing_process(workdir, text: str) -> None:
|
159 | 162 | 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) |
| 163 | + # with open(workdir / "type.ahk", "w", encoding="utf-8") as f: |
| 164 | + # f.write("SetKeyDelay 400, 100\n") # 400ms between keys, 100ms between down/up. |
| 165 | + # f.write(f"SendEvent \"{text}\"\n") |
| 166 | + # f.write("exit") |
| 167 | + # result = subprocess.run(["AutoHotkey.exe", "/ErrorStdOut", "type.ahk"], cwd=workdir) |
| 168 | + ahk.send(text, key_delay=400); |
166 | 169 | else:
|
167 | 170 | result = subprocess.run(["xdotool", "type", "--delay", "400", text])
|
168 |
| - logger.info(f"stdout: {result.stdout}") |
169 |
| - logger.info(f"stderr: {result.stderr}") |
170 |
| - assert result.returncode == 0 |
| 171 | + #logger.info(f"stdout: {result.stdout}") |
| 172 | + #logger.info(f"stderr: {result.stderr}") |
| 173 | + #assert result.returncode == 0 |
171 | 174 |
|
172 | 175 |
|
173 | 176 | def __get_parameters():
|
|
0 commit comments