diff --git a/display_server_interactions/__init__.py b/display_server_interactions/__init__.py index 4483153..b292060 100644 --- a/display_server_interactions/__init__.py +++ b/display_server_interactions/__init__.py @@ -14,7 +14,7 @@ OSNotSupportedError as __OSNotSupportedError ) -__version__ = "0.0.dev9" +__version__ = "0.0.dev10" __author__ = "Commandcracker" __os_name = __system().lower() diff --git a/display_server_interactions/windows.py b/display_server_interactions/windows.py index 96caa5c..93bdcb9 100644 --- a/display_server_interactions/windows.py +++ b/display_server_interactions/windows.py @@ -42,7 +42,8 @@ """ SRCCOPY = 0x00CC0020 WM_CHAR = 0x0102 - +WM_KEYDOWN = 0x0100 +WM_KEYUP = 0x0101 # pylint: disable=too-few-public-methods @@ -149,7 +150,38 @@ def get_image(self, geometry: Optional[Box] = None): return img def send_chr(self, character: chr) -> None: - user32.PostMessageW(self.window, WM_CHAR, ord(character), 0) + vk_map = { + "return": 0x0D, + "tab": 0x09, + "shift_l": 0xA0, + "shift_r": 0xA1, + "control_r": 0x11, + "control_r": 0x11, + "alt_l": 0x12, + "alt_r": 0x12, + "pause": 0x13, + "caps_lock": 0x14, + "escape": 0x1B, + "space": 0x20, + "prior": 0x21, + "next": 0x22, + "end": 0x23, + "home": 0x24, + "left": 0x25, + "up": 0x26, + "right": 0x27, + "down": 0x28, + "print": 0x2C, + "insert": 0x2D, + "delete": 0x2E + } + + vk = vk_map.get(character.lower()) + if vk is None: + user32.PostMessageW(self.window, WM_CHAR, ord(character), 0) + else: + user32.PostMessageW(self.window, WM_KEYDOWN, vk, 0) + user32.PostMessageW(self.window, WM_KEYUP, vk, 0) def send_str(self, string: str) -> None: for character in string: