修QQ读不到消息:恢复键盘导航Esc→Esc→Enter不切会话
This commit is contained in:
+25
-5
@@ -401,11 +401,24 @@ class MessageMonitor:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# 注意:不再执行 {Esc}{Esc}{Down}{Enter} 键盘导航,避免每次 poll
|
# 注意:不再执行 {Esc}{Esc}{Down}{Enter} 键盘导航,避免每次 poll
|
||||||
# 切换到不同会话导致读到不同消息集。直接 Ctrl+A/C 读取当前可见对话。
|
# 切换到不同会话导致读到不同消息集。改用 Esc→Esc→Enter
|
||||||
# 若需滚动到底部,用 PostMessage(不影响焦点)
|
# 回到会话列表后重新打开当前(同一)对话,确保消息区可读。
|
||||||
hwnd_current = self._cached_hwnd.get(platform)
|
variant = self._app_variant.get(platform, "")
|
||||||
if hwnd_current:
|
if variant in ("tim", "qq_nt"):
|
||||||
win32gui.PostMessage(hwnd_current, win32con.WM_VSCROLL, win32con.SB_BOTTOM, 0)
|
VK_ESC = 0x1B
|
||||||
|
VK_RETURN = 0x0D
|
||||||
|
VK_END = 0x23
|
||||||
|
VK_CONTROL = 0x11
|
||||||
|
# 取消弹窗/菜单,回到会话列表
|
||||||
|
self._send_key_press(VK_ESC, 0.08)
|
||||||
|
self._send_key_press(VK_ESC, 0.08)
|
||||||
|
# 重新打开当前选中的对话(同会话,不切换)
|
||||||
|
self._send_key_press(VK_RETURN, 0.4)
|
||||||
|
# Ctrl+End 滚动到底部
|
||||||
|
ctypes.windll.user32.keybd_event(VK_CONTROL, 0, 0, 0)
|
||||||
|
self._send_key_press(VK_END, 0.05)
|
||||||
|
ctypes.windll.user32.keybd_event(VK_CONTROL, 0, 2, 0)
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
# 用 SendInput 替代 auto.SendKeys(避免 ord() Unicode 解析 bug)
|
# 用 SendInput 替代 auto.SendKeys(避免 ord() Unicode 解析 bug)
|
||||||
VK_A = 0x41
|
VK_A = 0x41
|
||||||
@@ -530,6 +543,13 @@ class MessageMonitor:
|
|||||||
"""SendInput KEYBDINPUT keyup (KEYEVENTF_KEYUP=2)."""
|
"""SendInput KEYBDINPUT keyup (KEYEVENTF_KEYUP=2)."""
|
||||||
ctypes.windll.user32.keybd_event(vk, 0, 2, 0)
|
ctypes.windll.user32.keybd_event(vk, 0, 2, 0)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _send_key_press(vk: int, delay: float = 0.05):
|
||||||
|
"""SendInput single key press (down + up)."""
|
||||||
|
ctypes.windll.user32.keybd_event(vk, 0, 0, 0)
|
||||||
|
time.sleep(delay)
|
||||||
|
ctypes.windll.user32.keybd_event(vk, 0, 2, 0)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _send_ctrl_combo(vk: int):
|
def _send_ctrl_combo(vk: int):
|
||||||
"""Send Ctrl+<key>: Ctrl down → key down → key up → Ctrl up."""
|
"""Send Ctrl+<key>: Ctrl down → key down → key up → Ctrl up."""
|
||||||
|
|||||||
Reference in New Issue
Block a user