autoxkit 2.2.0__tar.gz → 2.2.1__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 (35) hide show
  1. {autoxkit-2.2.0 → autoxkit-2.2.1}/PKG-INFO +1 -1
  2. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/hook/hook_listener.py +19 -9
  3. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit.egg-info/PKG-INFO +1 -1
  4. {autoxkit-2.2.0 → autoxkit-2.2.1}/pyproject.toml +1 -1
  5. {autoxkit-2.2.0 → autoxkit-2.2.1}/LICENSE.txt +0 -0
  6. {autoxkit-2.2.0 → autoxkit-2.2.1}/README.md +0 -0
  7. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/__init__.py +0 -0
  8. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/__init__.py +0 -0
  9. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/adb.py +0 -0
  10. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/binary.py +0 -0
  11. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/client.py +0 -0
  12. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/control.py +0 -0
  13. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/control_backup.py +0 -0
  14. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/models.py +0 -0
  15. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/android/streams.py +0 -0
  16. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/constants.py +0 -0
  17. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/hook/__init__.py +0 -0
  18. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/hook/event.py +0 -0
  19. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/hook/hotkey_listener.py +0 -0
  20. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/match/__init__.py +0 -0
  21. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/match/match.py +0 -0
  22. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/mousekey/__init__.py +0 -0
  23. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/mousekey/input.py +0 -0
  24. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/mousekey/keyboard.py +0 -0
  25. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/mousekey/mouse.py +0 -0
  26. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/utils.py +0 -0
  27. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/window/__init__.py +0 -0
  28. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/window/window.py +0 -0
  29. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/window/window_action.py +0 -0
  30. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit/window/window_match.py +0 -0
  31. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit.egg-info/SOURCES.txt +0 -0
  32. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit.egg-info/dependency_links.txt +0 -0
  33. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit.egg-info/requires.txt +0 -0
  34. {autoxkit-2.2.0 → autoxkit-2.2.1}/autoxkit.egg-info/top_level.txt +0 -0
  35. {autoxkit-2.2.0 → autoxkit-2.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autoxkit
3
- Version: 2.2.0
3
+ Version: 2.2.1
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
@@ -1,13 +1,16 @@
1
-
2
1
  # hook_listener.py
3
2
  import ctypes
4
3
  from ctypes import wintypes, Structure, POINTER, CFUNCTYPE, byref
5
4
  import threading
5
+ import time
6
6
  from .event import KeyEvent, MouseEvent
7
7
  from ..constants import Hex_Hook_Code
8
8
 
9
9
  HHC = Hex_Hook_Code
10
10
 
11
+ # 消息泵空闲轮询间隔(秒),无消息时休眠此时间以释放 CPU
12
+ MSG_POLL_INTERVAL = 0.001
13
+
11
14
  # ---------- 结构体定义 ----------
12
15
  class KBDLLHOOKSTRUCT(Structure):
13
16
  _fields_ = [
@@ -30,7 +33,7 @@ class MSLLHOOKSTRUCT(Structure):
30
33
  # ---------- 回调类型 ----------
31
34
  HOOKPROC = CFUNCTYPE(ctypes.c_long, ctypes.c_int, wintypes.WPARAM, wintypes.LPARAM)
32
35
 
33
- # ---------- 加载 DLL 并声明 API 签名(你指出必须有的部分) ----------
36
+ # ---------- 加载 DLL 并声明 API 签名 ----------
34
37
  user32 = ctypes.WinDLL('user32', use_last_error=True)
35
38
  kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
36
39
 
@@ -163,7 +166,9 @@ class HookListener:
163
166
  if result is True:
164
167
  return 1 # 截断事件传播
165
168
  except ValueError as e:
166
- raise e
169
+ print(f"[hook_listener] ValueError in keydown callback: {e}", file=__import__('sys').stderr)
170
+ except Exception as e:
171
+ print(f"[hook_listener] Exception in keydown callback: {e}", file=__import__('sys').stderr)
167
172
  elif wParam in (HHC["KeyUp"], HHC["SysKeyUp"]):
168
173
  event = KeyEvent('KeyUp', kbd.vkCode)
169
174
  for cb in self._on_keyup:
@@ -172,9 +177,11 @@ class HookListener:
172
177
  if result is True:
173
178
  return 1 # 截断事件传播
174
179
  except ValueError as e:
175
- raise e
180
+ print(f"[hook_listener] ValueError in keyup callback: {e}", file=__import__('sys').stderr)
181
+ except Exception as e:
182
+ print(f"[hook_listener] Exception in keyup callback: {e}", file=__import__('sys').stderr)
176
183
  except Exception as e:
177
- raise e
184
+ print(f"[hook_listener] Exception in _keyboard_proc: {e}", file=__import__('sys').stderr)
178
185
 
179
186
  return user32.CallNextHookEx(self.keyboard_hook, nCode, wParam, lParam)
180
187
 
@@ -194,7 +201,7 @@ class HookListener:
194
201
  if result is True:
195
202
  return 1 # 截断事件传播
196
203
  except Exception as e:
197
- raise e
204
+ print(f"[hook_listener] Exception in mousedown callback: {e}", file=__import__('sys').stderr)
198
205
 
199
206
  elif wParam in (HHC["MLeftUp"], HHC["MRightUp"], HHC["MiddleUp"], HHC["XUp"]):
200
207
  button = self._get_mouse_button(wParam, ms.mouseData)
@@ -205,9 +212,9 @@ class HookListener:
205
212
  if result is True:
206
213
  return 1 # 截断事件传播
207
214
  except Exception as e:
208
- raise e
215
+ print(f"[hook_listener] Exception in mouseup callback: {e}", file=__import__('sys').stderr)
209
216
  except Exception as e:
210
- raise e
217
+ print(f"[hook_listener] Exception in _mouse_proc: {e}", file=__import__('sys').stderr)
211
218
 
212
219
  return user32.CallNextHookEx(self.mouse_hook, nCode, wParam, lParam)
213
220
 
@@ -276,9 +283,12 @@ class HookListener:
276
283
  if user32.PeekMessageW(byref(msg), 0, 0, 0, 1): # PM_REMOVE = 1
277
284
  user32.TranslateMessage(byref(msg))
278
285
  user32.DispatchMessageW(byref(msg))
286
+ else:
287
+ # 无消息时休眠,避免 CPU 忙等
288
+ time.sleep(MSG_POLL_INTERVAL)
279
289
  except Exception:
280
290
  # 记录异常但不退出循环,确保钩子持续工作
281
- # 回调中的异常应由上层自行处理
291
+ print("[hook_listener] Exception in message pump", file=__import__('sys').stderr)
282
292
  continue
283
293
 
284
294
  # 离开循环之前确保取消钩子
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autoxkit
3
- Version: 2.2.0
3
+ Version: 2.2.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "autoxkit"
7
- version = "2.2.0"
7
+ version = "2.2.1"
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"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes