add key down key up

This commit is contained in:
Jing Hua
2023-11-26 23:54:43 +08:00
parent ddd1da2d78
commit 6dee58252e
2 changed files with 31 additions and 2 deletions

View File

@@ -18,7 +18,9 @@ class Action(Enum):
MOUSE_UP = 2
MOUSE_MOVE = 3
KEY = 4
TYPE = 5
KEY_DOWN = 5
KEY_UP = 6
TYPE = 7
VM_TYPE = Literal['ubuntu', 'windows']
@@ -163,6 +165,12 @@ class DesktopEnv(gym.Env):
elif action_type == Action.KEY:
key_sequence = ''.join(map(chr, action['key'])) # Convert integer array to string
self.keyboard_controller.key(key_sequence)
elif action_type == Action.KEY_DOWN:
key_sequence = ''.join(map(chr, action['key'])) # Convert integer array to string
self.keyboard_controller.key_down(key_sequence)
elif action_type == Action.KEY_UP:
key_sequence = ''.join(map(chr, action['key'])) # Convert integer array to string
self.keyboard_controller.key_up(key_sequence)
elif action_type == Action.TYPE:
text = ''.join(map(chr, action['text'])) # Convert integer array to string
self.keyboard_controller.type(text)