事件点击改文字中心 + 卡包刷新按 OCR + 运行数据归档
- 事件: 点击点从「选项标记」改成选项文字自己的中心(_option_click_pos)。11-18 实测同一个 选项被点 10 次还在, 标记常落在行首装饰上 - 事件兜底: LCP_EVENT_FALLBACK=1 时表里没有的事件点第 1 项, 不再被上游「无法解决事件→回主界面」 - 卡包刷新: 改成 OCR 找右上角「刷新」点文字中心(找不到退回模板), 记 decisions theme_pack/refresh_click - 驱动点击: 点击点必须落在游戏客户区内(否则拒绝), 修「老是打开回收站」(blank 点击点到桌面左上角) - docs/feedback/runs/2026-11-15_2026-11-21: 20 轮过滤后的日志(1.6MB, 原始 110MB) + decisions.jsonl 原样(1868 条) + INDEX.md 汇总 单测: 750 passed。
This commit is contained in:
+33
-5
@@ -320,11 +320,21 @@ def click_point_is_on_foreground(sx, sy, hwnd=None):
|
||||
if not fg:
|
||||
return False, '当前没有前台窗口(GetForegroundWindow=0)'
|
||||
if hwnd:
|
||||
if fg == hwnd or _api('user32', 'IsChild', wintypes.BOOL,
|
||||
[wintypes.HWND, wintypes.HWND])(hwnd, fg):
|
||||
return True, 'ok'
|
||||
return False, ('前台不是目标窗口(前台=%r, 目标=%r) —— 这次点击会打到别的窗口'
|
||||
% (window_title(fg), window_title(hwnd)))
|
||||
if not (fg == hwnd or _api('user32', 'IsChild', wintypes.BOOL,
|
||||
[wintypes.HWND, wintypes.HWND])(hwnd, fg)):
|
||||
return False, ('前台不是目标窗口(前台=%r, 目标=%r) —— 这次点击会打到别的窗口'
|
||||
% (window_title(fg), window_title(hwnd)))
|
||||
# 2026-11-18: 前台是游戏也不代表点击点还在游戏里。blank 点击用的是客户区 (1,1),
|
||||
# 窗口一旦移动/缩放而坐标是旧值时, 屏幕点会落到窗口外的桌面左上角 —— 那里正好是
|
||||
# 回收站图标, 于是"老是弹出回收站"。这里补一次客户区包含判断。
|
||||
try:
|
||||
area = client_area_on_screen(hwnd)
|
||||
except OSError as e:
|
||||
return False, str(e)
|
||||
if not (area[0] <= sx < area[2] and area[1] <= sy < area[3]):
|
||||
return False, ('点击点(%d,%d)不在游戏客户区 %d,%d-%d,%d 内 —— 会点到桌面/别的窗口'
|
||||
% (sx, sy, area[0], area[1], area[2], area[3]))
|
||||
return True, 'ok'
|
||||
pt = wintypes.POINT(int(sx), int(sy))
|
||||
rect = wintypes.RECT()
|
||||
get_rect = _api('user32', 'GetWindowRect', wintypes.BOOL,
|
||||
@@ -337,6 +347,24 @@ def click_point_is_on_foreground(sx, sy, hwnd=None):
|
||||
return True, 'ok'
|
||||
|
||||
|
||||
def client_area_on_screen(hwnd):
|
||||
"""游戏客户区在屏幕上的矩形 (left, top, right, bottom)。"""
|
||||
if not hwnd:
|
||||
raise OSError('没有游戏窗口句柄')
|
||||
rect = wintypes.RECT()
|
||||
fn = _api('user32', 'GetClientRect', wintypes.BOOL,
|
||||
[wintypes.HWND, ctypes.POINTER(wintypes.RECT)])
|
||||
if not fn(hwnd, ctypes.byref(rect)):
|
||||
raise OSError('GetClientRect 失败, 无法确认点击点在游戏内')
|
||||
tl = wintypes.POINT(rect.left, rect.top)
|
||||
br = wintypes.POINT(rect.right, rect.bottom)
|
||||
c2s = _api('user32', 'ClientToScreen', wintypes.BOOL,
|
||||
[wintypes.HWND, ctypes.POINTER(wintypes.POINT)])
|
||||
if not c2s(hwnd, ctypes.byref(tl)) or not c2s(hwnd, ctypes.byref(br)):
|
||||
raise OSError('ClientToScreen 失败, 无法确认点击点在游戏内')
|
||||
return (tl.x, tl.y, br.x, br.y)
|
||||
|
||||
|
||||
def client_to_screen(hwnd, x, y):
|
||||
"""游戏客户区坐标 -> 屏幕坐标。"""
|
||||
if not hwnd:
|
||||
|
||||
Reference in New Issue
Block a user