implement action replay for vscode and gimp evaluation

This commit is contained in:
Siheng Zhao
2024-01-13 17:53:13 +08:00
parent d6f694da1c
commit 105fd35683
5 changed files with 78 additions and 6 deletions

View File

@@ -0,0 +1,19 @@
from typing import List, Dict, Any
def get_replay(env, trajectory: List[Dict[str, Any]]) -> None:
def parse(action):
if action["type"] == "hotkey":
keys = "', '".join(action["param"])
return f"pyautogui.hotkey('{keys}')"
if action["type"] == "typewrite":
text = action["param"]
return f"pyautogui.typewrite('{text}')"
if action["type"] == "press":
key = action["param"]
return f"pyautogui.press('{key}')"
for action in trajectory:
env.controller.execute_python_command(parse(action))