autoxkit 2.2.1__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {autoxkit-2.2.1 → autoxkit-2.4.0}/PKG-INFO +8 -1
  2. {autoxkit-2.2.1 → autoxkit-2.4.0}/README.md +7 -0
  3. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/constants.py +2 -1
  4. autoxkit-2.4.0/autoxkit/hook/event.py +41 -0
  5. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/hook/hook_listener.py +41 -3
  6. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/mousekey/mouse.py +3 -3
  7. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/window/window_action.py +5 -5
  8. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit.egg-info/PKG-INFO +8 -1
  9. {autoxkit-2.2.1 → autoxkit-2.4.0}/pyproject.toml +1 -1
  10. autoxkit-2.2.1/autoxkit/hook/event.py +0 -36
  11. {autoxkit-2.2.1 → autoxkit-2.4.0}/LICENSE.txt +0 -0
  12. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/__init__.py +0 -0
  13. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/__init__.py +0 -0
  14. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/adb.py +0 -0
  15. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/binary.py +0 -0
  16. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/client.py +0 -0
  17. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/control.py +0 -0
  18. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/control_backup.py +0 -0
  19. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/models.py +0 -0
  20. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/android/streams.py +0 -0
  21. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/hook/__init__.py +0 -0
  22. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/hook/hotkey_listener.py +0 -0
  23. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/match/__init__.py +0 -0
  24. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/match/match.py +0 -0
  25. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/mousekey/__init__.py +0 -0
  26. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/mousekey/input.py +0 -0
  27. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/mousekey/keyboard.py +0 -0
  28. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/utils.py +0 -0
  29. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/window/__init__.py +0 -0
  30. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/window/window.py +0 -0
  31. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit/window/window_match.py +0 -0
  32. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit.egg-info/SOURCES.txt +0 -0
  33. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit.egg-info/dependency_links.txt +0 -0
  34. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit.egg-info/requires.txt +0 -0
  35. {autoxkit-2.2.1 → autoxkit-2.4.0}/autoxkit.egg-info/top_level.txt +0 -0
  36. {autoxkit-2.2.1 → autoxkit-2.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autoxkit
3
- Version: 2.2.1
3
+ Version: 2.4.0
4
4
  Summary: Python library for Windows automation and Android device screen casting and control
5
5
  Author-email: YorickFin <1582456060@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -91,11 +91,17 @@ def mouse_up(event: MouseEvent):
91
91
  return False
92
92
 
93
93
 
94
+ def mouse_move(event: MouseEvent):
95
+ print(event.action, event.button, event.position)
96
+ return False
97
+
98
+
94
99
  hook_listener = HookListener()
95
100
  hook_listener.add_handler('keydown', key_down)
96
101
  hook_listener.add_handler('keyup', key_up)
97
102
  hook_listener.add_handler('mousedown', mouse_down)
98
103
  hook_listener.add_handler('mouseup', mouse_up)
104
+ hook_listener.add_handler('mousemove', mouse_move)
99
105
  hook_listener.start()
100
106
 
101
107
  print("当前鼠标位置:", hook_listener.get_mouse_position())
@@ -105,6 +111,7 @@ if __name__ == '__main__':
105
111
  hook_listener.wait()
106
112
  except Exception:
107
113
  hook_listener.stop()
114
+
108
115
  ```
109
116
 
110
117
  更多示例代码请参考 [examples](examples)
@@ -68,11 +68,17 @@ def mouse_up(event: MouseEvent):
68
68
  return False
69
69
 
70
70
 
71
+ def mouse_move(event: MouseEvent):
72
+ print(event.action, event.button, event.position)
73
+ return False
74
+
75
+
71
76
  hook_listener = HookListener()
72
77
  hook_listener.add_handler('keydown', key_down)
73
78
  hook_listener.add_handler('keyup', key_up)
74
79
  hook_listener.add_handler('mousedown', mouse_down)
75
80
  hook_listener.add_handler('mouseup', mouse_up)
81
+ hook_listener.add_handler('mousemove', mouse_move)
76
82
  hook_listener.start()
77
83
 
78
84
  print("当前鼠标位置:", hook_listener.get_mouse_position())
@@ -82,6 +88,7 @@ if __name__ == '__main__':
82
88
  hook_listener.wait()
83
89
  except Exception:
84
90
  hook_listener.stop()
91
+
85
92
  ```
86
93
 
87
94
  更多示例代码请参考 [examples](examples)
@@ -45,9 +45,10 @@ Hex_Hook_Code = {
45
45
  "Key_LL": 0x000D,
46
46
  "KeyDown": 0x0100, "KeyUp": 0x0101, "SysKeyDown": 0x0104, "SysKeyUp": 0x0105,
47
47
  "Mouse_LL": 0x000E,
48
+ "MWheel": 0x020A,
48
49
  "MLeftDown": 0x0201, "MLeftUp": 0x0202,
49
50
  "MRightDown": 0x0204, "MRightUp": 0x0205,
50
51
  "MiddleDown": 0x0207, "MiddleUp": 0x0208,
51
52
  "XDown": 0x020B, "XUp": 0x020C, "MSide1": 0x0001, "MSide2": 0x0002,
52
53
  "PM_REMOVE": 0x0001,
53
- }
54
+ }
@@ -0,0 +1,41 @@
1
+ from ..constants import Hex_Key_Code
2
+
3
+ class KeyEvent:
4
+ """
5
+ 键盘事件
6
+ Args:
7
+ action (str): 事件类型,"keydown"或"keyup"
8
+ vk_code : 按键的16进制虚拟键码
9
+ Attributes:
10
+ action (str): 事件类型,"keydown"或"keyup"
11
+ key_code : 按键的16进制虚拟键码
12
+ key_name (str): 按键名称,例如"Ctrl"、"A" 等
13
+ """
14
+ def __init__(self, action, vk_code):
15
+ self.action = action
16
+ self.key_code = vk_code
17
+ name = next((k for k, v in Hex_Key_Code.items() if v == vk_code), None)
18
+ self.key_name = name if name else str(vk_code)
19
+
20
+ class MouseEvent:
21
+ """
22
+ 鼠标事件
23
+ Args:
24
+ action (str): 事件类型,"MouseDown"、"MouseUp"或"MouseMove"
25
+ button (str): 鼠标按键,"MLeft"、"MRight"、"Middle"、"MSide1"、"MSide2"、
26
+ "MUWheel"或"MDWheel",MouseMove时为None
27
+ x (int): 鼠标x坐标
28
+ y (int): 鼠标y坐标
29
+ distance (int): 滚轮滚动距离,正值为向上滚动,负值为向下滚动。非滚轮事件时为0
30
+ Attributes:
31
+ action (str): 事件类型,"MouseDown"、"MouseUp"或"MouseMove"
32
+ button (str): 鼠标按键,"MLeft"、"MRight"、"Middle"、"MSide1"、"MSide2"、
33
+ "MUWheel"或"MDWheel",MouseMove时为None
34
+ position (tuple): 鼠标位置,(x, y)格式
35
+ distance (int): 滚轮滚动距离,正值为向上滚动,负值为向下滚动。非滚轮事件时为0
36
+ """
37
+ def __init__(self, action, button, x, y, distance=0):
38
+ self.action = action
39
+ self.button = button
40
+ self.position = (x, y)
41
+ self.distance = distance
@@ -76,6 +76,7 @@ class HookListener:
76
76
  self._on_keyup = []
77
77
  self._on_mousedown = []
78
78
  self._on_mouseup = []
79
+ self._on_mousemove = []
79
80
 
80
81
  # 钩子与线程状态
81
82
  self._thread = None
@@ -110,6 +111,8 @@ class HookListener:
110
111
  self._on_mousedown.append(func)
111
112
  elif event_type == "mouseup":
112
113
  self._on_mouseup.append(func)
114
+ elif event_type == "mousemove":
115
+ self._on_mousemove.append(func)
113
116
  else:
114
117
  raise ValueError("unknown event_type: " + str(event_type))
115
118
 
@@ -133,6 +136,8 @@ class HookListener:
133
136
  target = self._on_mousedown
134
137
  elif event_type == "mouseup":
135
138
  target = self._on_mouseup
139
+ elif event_type == "mousemove":
140
+ target = self._on_mousemove
136
141
  else:
137
142
  raise ValueError("unknown event_type: " + str(event_type))
138
143
  try:
@@ -192,7 +197,17 @@ class HookListener:
192
197
  ms = ctypes.cast(lParam, POINTER(MSLLHOOKSTRUCT)).contents
193
198
  x, y = ms.pt.x, ms.pt.y
194
199
 
195
- if wParam in (HHC["MLeftDown"], HHC["MRightDown"], HHC["MiddleDown"], HHC["XDown"]):
200
+ if wParam == 0x0200: # WM_MOUSEMOVE
201
+ event = MouseEvent("MouseMove", None, x, y)
202
+ for cb in self._on_mousemove:
203
+ try:
204
+ result = cb(event)
205
+ if result is True:
206
+ return 1 # 截断事件传播
207
+ except Exception as e:
208
+ print(f"[hook_listener] Exception in mousemove callback: {e}", file=__import__('sys').stderr)
209
+
210
+ elif wParam in (HHC["MLeftDown"], HHC["MRightDown"], HHC["MiddleDown"], HHC["XDown"]):
196
211
  button = self._get_mouse_button(wParam, ms.mouseData)
197
212
  event = MouseEvent("MouseDown", button, x, y)
198
213
  for cb in self._on_mousedown:
@@ -212,12 +227,35 @@ class HookListener:
212
227
  if result is True:
213
228
  return 1 # 截断事件传播
214
229
  except Exception as e:
215
- print(f"[hook_listener] Exception in mouseup callback: {e}", file=__import__('sys').stderr)
230
+ print(f"[hook_listener] Exception in mouseup callback: {e}", file=__import__("sys").stderr)
231
+
232
+ elif wParam == HHC["MWheel"]:
233
+ delta = ctypes.c_short(ms.mouseData >> 16).value
234
+ if delta > 0:
235
+ event = MouseEvent("MouseUp", "MUWheel", x, y, distance=delta)
236
+ for cb in self._on_mouseup:
237
+ try:
238
+ result = cb(event)
239
+ if result is True:
240
+ return 1
241
+ except Exception as e:
242
+ print(f"[hook_listener] Exception in mouseup callback: {e}", file=__import__("sys").stderr)
243
+ elif delta < 0:
244
+ event = MouseEvent("MouseDown", "MDWheel", x, y, distance=delta)
245
+ for cb in self._on_mousedown:
246
+ try:
247
+ result = cb(event)
248
+ if result is True:
249
+ return 1
250
+ except Exception as e:
251
+ print(f"[hook_listener] Exception in mousedown callback: {e}", file=__import__("sys").stderr)
252
+
216
253
  except Exception as e:
217
- print(f"[hook_listener] Exception in _mouse_proc: {e}", file=__import__('sys').stderr)
254
+ print(f"[hook_listener] Exception in _mouse_proc: {e}", file=__import__("sys").stderr)
218
255
 
219
256
  return user32.CallNextHookEx(self.mouse_hook, nCode, wParam, lParam)
220
257
 
258
+
221
259
  # 辅助函数:获取鼠标按键名称
222
260
  def _get_mouse_button(self, wParam, mouseData):
223
261
  if wParam in (HHC["MLeftDown"], HHC["MLeftUp"]):
@@ -114,18 +114,18 @@ class Mouse:
114
114
 
115
115
  time.sleep(step_interval)
116
116
 
117
- def wheel_scroll(self, amount: int, x: int=None, y: int=None):
117
+ def mouse_wheel(self, distance: int, x: int=None, y: int=None):
118
118
  """
119
119
  垂直滚轮滚动
120
120
  Args:
121
121
  x (int): 目标X坐标
122
122
  y (int): 目标Y坐标
123
- amount (int): 滚动距离(正值向上,负值向下)
123
+ distance (int): 滚动距离(正值向上,负值向下)
124
124
  """
125
125
  x, y = self._verify_mouse_point(x, y)
126
126
  if x is not None and y is not None:
127
127
  self.mouse_move(x, y, steps=1)
128
- self._mouse_action(HMC["Wheel"], data=amount * 10)
128
+ self._mouse_action(HMC["Wheel"], data=distance * 120)
129
129
 
130
130
  def get_mouse_position(self):
131
131
  """
@@ -331,11 +331,11 @@ class WindowAction:
331
331
  # 等待一段时间
332
332
  time.sleep(step_interval)
333
333
 
334
- def send_mouse_wheel(self, amount: int, x: int=None, y: int=None, mode='send'):
334
+ def send_mouse_wheel(self, distance: int, x: int=None, y: int=None, mode='send'):
335
335
  """
336
336
  发送鼠标滚轮消息
337
337
  Args:
338
- amount (int): 滚动距离(正值向上,负值向下)
338
+ distance (int): 滚动距离(正值向上,负值向下)
339
339
  mode (str): 发送模式,'send', 'post', 'global'。默认 'send'
340
340
  """
341
341
  if not self.hwnd:
@@ -343,9 +343,9 @@ class WindowAction:
343
343
 
344
344
  if mode == 'global':
345
345
  if x is None or y is None:
346
- self.mouse.mouse_wheel(amount=amount)
346
+ self.mouse.mouse_wheel(distance=distance)
347
347
  else:
348
- self.mouse.mouse_wheel(self.client_point.x + x, self.client_point.y + y, amount)
348
+ self.mouse.mouse_wheel(self.client_point.x + x, self.client_point.y + y, distance)
349
349
  return
350
350
 
351
351
  # 获取当前鼠标位置(使用记录的位置,如果没有则使用窗口中心)
@@ -365,7 +365,7 @@ class WindowAction:
365
365
  # 确保使用屏幕坐标
366
366
  lparam = MAKELPARAM(x, y)
367
367
  # 高16位是滚轮滚动量,低16位是鼠标状态
368
- wparam = (amount << 16) | (self.mouse_state & 0xFFFF)
368
+ wparam = ((distance * 120) << 16) | (self.mouse_state & 0xFFFF)
369
369
 
370
370
  if mode == 'post':
371
371
  PostMessage(self.hwnd, WM_MOUSEWHEEL, wparam, lparam)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autoxkit
3
- Version: 2.2.1
3
+ Version: 2.4.0
4
4
  Summary: Python library for Windows automation and Android device screen casting and control
5
5
  Author-email: YorickFin <1582456060@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -91,11 +91,17 @@ def mouse_up(event: MouseEvent):
91
91
  return False
92
92
 
93
93
 
94
+ def mouse_move(event: MouseEvent):
95
+ print(event.action, event.button, event.position)
96
+ return False
97
+
98
+
94
99
  hook_listener = HookListener()
95
100
  hook_listener.add_handler('keydown', key_down)
96
101
  hook_listener.add_handler('keyup', key_up)
97
102
  hook_listener.add_handler('mousedown', mouse_down)
98
103
  hook_listener.add_handler('mouseup', mouse_up)
104
+ hook_listener.add_handler('mousemove', mouse_move)
99
105
  hook_listener.start()
100
106
 
101
107
  print("当前鼠标位置:", hook_listener.get_mouse_position())
@@ -105,6 +111,7 @@ if __name__ == '__main__':
105
111
  hook_listener.wait()
106
112
  except Exception:
107
113
  hook_listener.stop()
114
+
108
115
  ```
109
116
 
110
117
  更多示例代码请参考 [examples](examples)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "autoxkit"
7
- version = "2.2.1"
7
+ version = "2.4.0"
8
8
  description = "Python library for Windows automation and Android device screen casting and control"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,36 +0,0 @@
1
- from ..constants import Hex_Key_Code
2
-
3
- class KeyEvent:
4
- """
5
- 键盘事件
6
- Args:
7
- action (str): 事件类型,"keydown"或"keyup"
8
- vk_code : 按键的16进制虚拟键码
9
- Attributes:
10
- action (str): 事件类型,"keydown"或"keyup"
11
- key_code : 按键的16进制虚拟键码
12
- key_name (str): 按键名称,例如 "Ctrl"、"A" 等
13
- """
14
- def __init__(self, action, vk_code):
15
- self.action = action
16
- self.key_code = vk_code
17
- name = next((k for k, v in Hex_Key_Code.items() if v == vk_code), None)
18
- self.key_name = name if name else str(vk_code)
19
-
20
- class MouseEvent:
21
- """
22
- 鼠标事件
23
- Args:
24
- action (str): 事件类型,"MouseDown"或"MouseUp"
25
- button (str): 鼠标按钮,"MLeft"、"MRight"、"MMiddle"、"side1"、"side2"
26
- x (int): 鼠标x坐标
27
- y (int): 鼠标y坐标
28
- Attributes:
29
- action (str): 事件类型,"MouseDown"或"MouseUp"
30
- button (str): 鼠标按钮,"MLeft"、"MRight"、"MMiddle"、"side1"、"side2"
31
- position (tuple): 鼠标位置,(x, y)格式
32
- """
33
- def __init__(self, action, button, x, y):
34
- self.action = action
35
- self.button = button
36
- self.position = (x, y)
File without changes
File without changes
File without changes
File without changes