This commit is contained in:
恍兮惚兮 2024-08-21 09:03:14 +08:00
parent 80e1899466
commit 9341aac0b6
2 changed files with 11 additions and 4 deletions

View File

@ -121,9 +121,16 @@ class ocrtext(basetext):
triggered = True
laststate = this
if triggered and gobject.baseobject.hwnd:
p1 = windows.GetWindowThreadProcessId(gobject.baseobject.hwnd)
p2 = windows.GetWindowThreadProcessId(windows.GetForegroundWindow())
triggered = p1 == p2
for _ in range(2):
# 切换前台窗口
p1 = windows.GetWindowThreadProcessId(gobject.baseobject.hwnd)
p2 = windows.GetWindowThreadProcessId(
windows.GetForegroundWindow()
)
triggered = p1 == p2
if triggered:
break
time.sleep(0.1)
if triggered:
time.sleep(globalconfig["ocr_trigger_delay"])
for _ in range(len(self.savelastimg)):

View File

@ -42,7 +42,7 @@ OCR的结果是不稳定的经常对于图片的微小扰动会使文本发
### 鼠标键盘触发+等待稳定
以下鼠标键盘事件将触发该方法按下鼠标左键、按下Enter、松开Ctrl、松开Shift、松开Alt
以下鼠标键盘事件将触发该方法按下鼠标左键、按下Enter、松开Ctrl、松开Shift、松开Alt。如果绑定了游戏窗口,则仅当游戏窗口为前台窗口时,才会触发方法。
触发该方法后,由于需要等待游戏渲染新的文本,或文本可能不是立即出现(文本速度不是最快),因此需要稍微等待一小段时间,直到显示的文本稳定。