Explorar o código

Merge nearaura window-title and shrine exploration fixes

Integrate fe65e54b..a4d19403 (fb605636 and a4d19403) from the fallback
after runhey returned Repository not found. The fallback tip inspected
was 1ad372dc. Leave b2f02602 and its containing merge history outside this
merge because it extends access to another application's login tokens.

Skip foreground and minimize operations for empty window titles. Use the
upstream shrine exploration PNG unchanged, with its matching 49x76 crop,
search region and threshold. Both fixes were missing locally. The merge
preserves local scheduler, costume routing and unrelated asset changes.

587 tests passed in tests/ and the two FrogBoss suites, with three existing
deprecation warnings. Checked syntax, imports, mocked window enumeration,
runtime costume lookup, upstream PNG bytes, JSON and positive/negative
template matching at desktop and emulator padding. Diff check passed.
Validation was offline.
unknown hai 16 horas
pai
achega
b2c50fed46

+ 17 - 2
module/device/platform2/platform_windows.py

@@ -19,6 +19,11 @@ from ctypes import wintypes
 class EmulatorUnknown(Exception):
     pass
 
+def _window_keyword(window_name) -> str:
+    """窗口标题关键字,空标题返回空串(调用方需自行跳过,否则会匹配所有窗口)"""
+    return (window_name or '').strip().lower()
+
+
 def minimize_by_name(window_name, convert_hidden=True):
     """
     按名称处理窗口状态
@@ -26,9 +31,14 @@ def minimize_by_name(window_name, convert_hidden=True):
         window_name (str): 窗口名称(支持部分匹配)
         convert_hidden (bool): 是否将隐藏窗口改为最小化
     """
+    keyword = _window_keyword(window_name)
+    if not keyword:
+        logger.warning('窗口标题为空,跳过最小化窗口')
+        return
+
     def callback(hwnd, lParam):
         title = get_window_title(hwnd)
-        if window_name.lower() in title.lower():
+        if keyword in title.lower():
             # 检查窗口当前状态
             is_visible = ctypes.windll.user32.IsWindowVisible(hwnd)
             
@@ -49,10 +59,15 @@ def find_hwnd_by_name(window_name):
     """
     枚举所有窗口,返回第一个匹配名称的 hwnd
     """
+    keyword = _window_keyword(window_name)
+    # 空标题会匹配所有窗口,随后对任意系统窗口 ShowWindow 可能导致调用线程永久阻塞
+    if not keyword:
+        return None
+
     target = None
     def callback(hwnd, lParam):
         title = get_window_title(hwnd)
-        if window_name.lower() in title.lower():
+        if keyword in title.lower():
             nonlocal target
             target = hwnd
             return False  # 停止枚举

+ 4 - 1
script.py

@@ -667,7 +667,10 @@ class Script:
         if not self.config.script.device.run_background_only and IS_WINDOWS:
             from module.device.platform2.platform_windows import minimize_by_name, show_window_by_name
             target_window_name = self.config.script.device.handle  # 在这里输入你的具体窗口名称
-            if self.config.script.device.emulator_window_minimize:
+            if not target_window_name:
+                # 标题为空时不能去枚举窗口,否则会匹配到任意系统窗口并卡死
+                logger.info('script.device.handle 未配置,跳过模拟器窗口前置')
+            elif self.config.script.device.emulator_window_minimize:
                 minimize_by_name(target_window_name)
                 logger.info(f'重新显示: {target_window_name}')
             else:

+ 1 - 1
tasks/Component/Costume/assets.py

@@ -242,7 +242,7 @@ class CostumeAssets:
 	# description 
 	I_CHECK_MAIN_9 = RuleImage(roi_front=(764,117,134,42), roi_back=(149,109,1099,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main9/main9_check_main_9.png")
 	# description 
-	I_MAIN_GOTO_EXPLORATION_9 = RuleImage(roi_front=(553,107,31,30), roi_back=(234,98,904,68), threshold=0.3, method="Template matching", file="./tasks/Component/Costume/main9/main9_main_goto_exploration_9.png")
+	I_MAIN_GOTO_EXPLORATION_9 = RuleImage(roi_front=(537,113,49,76), roi_back=(300,60,680,200), threshold=0.75, method="Template matching", file="./tasks/Component/Costume/main9/main9_main_goto_exploration_9.png")
 	#  
 	I_MAIN_GOTO_SUMMON_9 = RuleImage(roi_front=(970,210,35,29), roi_back=(609,194,623,68), threshold=0.25, method="Template matching", file="./tasks/Component/Costume/main9/main9_main_goto_summon_9.png")
 	# description 

+ 3 - 3
tasks/Component/Costume/main9/image.json

@@ -11,10 +11,10 @@
   {
     "itemName": "main_goto_exploration_9",
     "imageName": "main9_main_goto_exploration_9.png",
-    "roiFront": "553,107,31,30",
-    "roiBack": "234,98,904,68",
+    "roiFront": "537,113,49,76",
+    "roiBack": "300,60,680,200",
     "method": "Template matching",
-    "threshold": 0.3,
+    "threshold": 0.75,
     "description": "description"
   },
   {

BIN=BIN
tasks/Component/Costume/main9/main9_main_goto_exploration_9.png