|
7 | 7 | if sys.platform not in ["win32", "cygwin", "msys"]: |
8 | 8 | raise AutoControlException(windows_import_error) |
9 | 9 |
|
10 | | -from je_auto_control.windows.core.utils.win32_ctype_input import Input |
| 10 | +from je_auto_control.windows.core.utils.win32_ctype_input import Input, user32 |
11 | 11 | from je_auto_control.windows.core.utils.win32_vk import win32_LEFTDOWN |
12 | 12 | from je_auto_control.windows.core.utils.win32_vk import win32_LEFTUP |
13 | 13 | from je_auto_control.windows.core.utils.win32_vk import win32_MIDDLEDOWN |
@@ -50,7 +50,7 @@ def mouse_event(event, x: int, y: int, dwData: int = 0) -> None: |
50 | 50 | ctypes.windll.user32.mouse_event(event, ctypes.c_long(converted_x), ctypes.c_long(converted_y), dwData, 0) |
51 | 51 |
|
52 | 52 |
|
53 | | -def position() -> [Tuple[int, int], None]: |
| 53 | +def position() -> tuple[int, int] | None: |
54 | 54 | """ |
55 | 55 | get mouse position |
56 | 56 | """ |
@@ -102,10 +102,16 @@ def click_mouse(mouse_keycode: int, x: int = None, y: int = None) -> None: |
102 | 102 | release_mouse(mouse_keycode) |
103 | 103 |
|
104 | 104 |
|
105 | | -def scroll(scroll_value: int, x: int = None, y: int = None) -> None: |
| 105 | +def scroll(scroll_value: int, x: int = None, y: int = None) -> None: |
106 | 106 | """ |
107 | 107 | :param scroll_value scroll count |
108 | 108 | :param x scroll x |
109 | 109 | :param y scroll y |
110 | 110 | """ |
111 | 111 | mouse_event(win32_WHEEL, x, y, dwData=scroll_value) |
| 112 | + |
| 113 | + |
| 114 | +def send_mouse_event_to_window(window, mouse_keycode: int, x: int = None, y: int = None): |
| 115 | + lparam = (y << 16) | x |
| 116 | + user32.PostMessageW(window, mouse_keycode, 1, lparam) |
| 117 | + user32.PostMessageW(window, mouse_keycode, 0, lparam) |
0 commit comments