diff --git a/display_server_interactions/__init__.py b/display_server_interactions/__init__.py index eaa19f4..bd92ab2 100644 --- a/display_server_interactions/__init__.py +++ b/display_server_interactions/__init__.py @@ -3,7 +3,7 @@ from platform import system as __system -__version__ = "0.0.dev6" +__version__ = "0.0.dev7" __author__ = "Commandcracker" __os_name = __system().lower() diff --git a/display_server_interactions/windows.py b/display_server_interactions/windows.py index 8a11694..b8b0388 100644 --- a/display_server_interactions/windows.py +++ b/display_server_interactions/windows.py @@ -54,8 +54,8 @@ def geometry(self) -> Box: rect = RECT() user32.GetWindowRect(self.window, byref(rect)) return Box( - x=0, - y=0, + x=rect.left, + y=rect.top, width=rect.right - rect.left, height=rect.bottom - rect.top ) @@ -99,14 +99,19 @@ def send_str(self, str: str) -> None: self.send_chr(chr) def warp_pointer(self, x: int, y: int, geometry: Box = None) -> None: - if geometry: - rel_x, rel_y = x - geometry.x, y - geometry.y - else: - rel_x, rel_y = x, y - point = POINT(rel_x, rel_y) + if geometry is None: + geometry = self.geometry + + x = x + geometry.x + y = y + geometry.y + + point = POINT(x, y) user32.SetCursorPos(point.x, point.y) def send_mouse_click(self, x: int, y: int, button: MouseButtons = MouseButtons.LEFT) -> None: + x = x + self.geometry.x + y = y + self.geometry.y + # Press and release the button down_code = 0 up_code = 0