mobile-mcp-ai 2.3.7__py3-none-any.whl → 2.3.8__py3-none-any.whl

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.
@@ -1005,9 +1005,10 @@ class BasicMobileToolsLite:
1005
1005
  """智能关闭弹窗
1006
1006
 
1007
1007
  策略:
1008
- 1. 从控件树找可能的关闭按钮(clickable=true,尺寸小,位置靠右上角)
1009
- 2. 如果找到,计算中心点并点击
1010
- 3. 如果没找到,返回需要视觉识别的提示
1008
+ 1. 从控件树找可能的关闭按钮(clickable=true,尺寸小)
1009
+ 2. 搜索范围:右上角、左上角、正下方中间、右下角、左下角
1010
+ 3. 如果找到,计算中心点并点击
1011
+ 4. 如果没找到,返回需要视觉识别的提示
1011
1012
  """
1012
1013
  try:
1013
1014
  # 获取屏幕尺寸
@@ -1043,14 +1044,44 @@ class BasicMobileToolsLite:
1043
1044
  center_x = (x1 + x2) // 2
1044
1045
  center_y = (y1 + y2) // 2
1045
1046
 
1046
- # 关闭按钮特征:尺寸小(30-100px),位置偏右上
1047
- if 30 <= width <= 100 and 30 <= height <= 100:
1048
- # 计算"右上角"得分(越靠右上越高)
1049
- right_score = center_x / screen_width # 0-1,越大越靠右
1050
- top_score = 1 - (center_y / screen_height) # 0-1,越大越靠上
1051
- # 只考虑屏幕上半部分、右半部分的按钮
1052
- if center_y < screen_height * 0.6 and center_x > screen_width * 0.5:
1053
- score = right_score * 0.5 + top_score * 0.5
1047
+ # 关闭按钮特征:尺寸小(20-120px)
1048
+ if 20 <= width <= 120 and 20 <= height <= 120:
1049
+ # 计算位置得分,支持多个区域
1050
+ score = 0
1051
+ position = ""
1052
+
1053
+ # 相对位置(0-1)
1054
+ rel_x = center_x / screen_width
1055
+ rel_y = center_y / screen_height
1056
+
1057
+ # 右上角(最常见): x > 0.6, y < 0.4
1058
+ if rel_x > 0.6 and rel_y < 0.4:
1059
+ score = 1.0 + (rel_x - 0.6) * 2 + (0.4 - rel_y) * 2
1060
+ position = "右上角"
1061
+
1062
+ # 左上角: x < 0.4, y < 0.4
1063
+ elif rel_x < 0.4 and rel_y < 0.4:
1064
+ score = 0.9 + (0.4 - rel_x) * 2 + (0.4 - rel_y) * 2
1065
+ position = "左上角"
1066
+
1067
+ # 正下方中间(弹窗底部): 0.3 < x < 0.7, y > 0.5
1068
+ elif 0.3 < rel_x < 0.7 and rel_y > 0.5:
1069
+ # 越靠近中间下方得分越高
1070
+ center_score = 1 - abs(rel_x - 0.5) * 2
1071
+ score = 0.8 + center_score * 0.5 + (rel_y - 0.5) * 0.5
1072
+ position = "正下方"
1073
+
1074
+ # 右下角: x > 0.6, y > 0.6
1075
+ elif rel_x > 0.6 and rel_y > 0.6:
1076
+ score = 0.7 + (rel_x - 0.6) + (rel_y - 0.6)
1077
+ position = "右下角"
1078
+
1079
+ # 左下角: x < 0.4, y > 0.6
1080
+ elif rel_x < 0.4 and rel_y > 0.6:
1081
+ score = 0.6 + (0.4 - rel_x) + (rel_y - 0.6)
1082
+ position = "左下角"
1083
+
1084
+ if score > 0:
1054
1085
  close_candidates.append({
1055
1086
  'bounds': bounds,
1056
1087
  'center_x': center_x,
@@ -1058,6 +1089,7 @@ class BasicMobileToolsLite:
1058
1089
  'width': width,
1059
1090
  'height': height,
1060
1091
  'score': score,
1092
+ 'position': position,
1061
1093
  'resource_id': elem.get('resource_id', ''),
1062
1094
  'text': elem.get('text', '')
1063
1095
  })
@@ -1066,7 +1098,8 @@ class BasicMobileToolsLite:
1066
1098
  return {
1067
1099
  "success": False,
1068
1100
  "message": "❌ 控件树未找到关闭按钮,请使用截图+视觉识别",
1069
- "suggestion": "尝试局部截图右上角区域,用 crop_x, crop_y, crop_size 参数"
1101
+ "suggestion": "先全屏截图让 AI 分析关闭按钮位置,再用局部截图精确定位",
1102
+ "screen_size": f"{screen_width}x{screen_height}"
1070
1103
  }
1071
1104
 
1072
1105
  # 按得分排序,取最可能的
@@ -1086,9 +1119,11 @@ class BasicMobileToolsLite:
1086
1119
 
1087
1120
  return {
1088
1121
  "success": True,
1089
- "message": f"✅ 点击关闭按钮: ({best['center_x']}, {best['center_y']})",
1122
+ "message": f"✅ 点击关闭按钮 ({best['position']}): ({best['center_x']}, {best['center_y']})",
1090
1123
  "bounds": best['bounds'],
1091
- "candidates_count": len(close_candidates)
1124
+ "position": best['position'],
1125
+ "candidates_count": len(close_candidates),
1126
+ "all_positions": [c['position'] for c in close_candidates[:5]]
1092
1127
  }
1093
1128
 
1094
1129
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mobile-mcp-ai
3
- Version: 2.3.7
3
+ Version: 2.3.8
4
4
  Summary: 移动端自动化 MCP Server - 支持 Android/iOS,AI 功能可选(基础工具不需要 AI)
5
5
  Home-page: https://github.com/test111ddff-hash/mobile-mcp-ai
6
6
  Author: douzi
@@ -1,7 +1,7 @@
1
1
  mobile_mcp/__init__.py,sha256=sQJZTL_sxQFzmcS7jOtS2AHCfUySz40vhX96N6u1qy4,816
2
2
  mobile_mcp/config.py,sha256=yaFLAV4bc2wX0GQPtZDo7OYF9E88tXV-av41fQsJwK4,4480
3
3
  mobile_mcp/core/__init__.py,sha256=ndMy-cLAIsQDG5op7gM_AIplycqZSZPWEkec1pEhvEY,170
4
- mobile_mcp/core/basic_tools_lite.py,sha256=SxUArYAc1wcm7DmaqcuNvaqFpxmS54YeJ_B5SHUvICo,63168
4
+ mobile_mcp/core/basic_tools_lite.py,sha256=Z4K9TTGR-vyvk7MzWGiE7Mwarnckqji5ToH5GpFKo5Y,64772
5
5
  mobile_mcp/core/device_manager.py,sha256=PX3-B5bJFnKNt6C8fT7FSY8JwD-ngZ3toF88bcOV9qA,8766
6
6
  mobile_mcp/core/dynamic_config.py,sha256=Ja1n1pfb0HspGByqk2_A472mYVniKmGtNEWyjUjmgK8,9811
7
7
  mobile_mcp/core/ios_client_wda.py,sha256=KudSbWTy-0l8OMQjXpsDYAiL59w7HVrw-i7ApfExJLA,18755
@@ -17,9 +17,9 @@ mobile_mcp/utils/__init__.py,sha256=8EH0i7UGtx1y_j_GEgdN-cZdWn2sRtZSEOLlNF9HRnY,
17
17
  mobile_mcp/utils/logger.py,sha256=Sqq2Nr0Y4p03erqcrbYKVPCGiFaNGHMcE_JwCkeOfU4,3626
18
18
  mobile_mcp/utils/xml_formatter.py,sha256=uwTRb3vLbqhT8O-udzWT7s7LsV-DyDUz2DkofD3hXOE,4556
19
19
  mobile_mcp/utils/xml_parser.py,sha256=QhL8CWbdmNDzmBLjtx6mEnjHgMFZzJeHpCL15qfXSpI,3926
20
- mobile_mcp_ai-2.3.7.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
21
- mobile_mcp_ai-2.3.7.dist-info/METADATA,sha256=YhwM3C6TMmdvvkfKXJ3jM4iDiwSYZk_1LlrY3uuT9xI,9423
22
- mobile_mcp_ai-2.3.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
23
- mobile_mcp_ai-2.3.7.dist-info/entry_points.txt,sha256=KB_FglozgPHBprSM1vFbIzGyheFuHFmGanscRdMJ_8A,68
24
- mobile_mcp_ai-2.3.7.dist-info/top_level.txt,sha256=lLm6YpbTv855Lbh8BIA0rPxhybIrvYUzMEk9OErHT94,11
25
- mobile_mcp_ai-2.3.7.dist-info/RECORD,,
20
+ mobile_mcp_ai-2.3.8.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
21
+ mobile_mcp_ai-2.3.8.dist-info/METADATA,sha256=E5wnga67GNtSj3kqS7_KDYGtt3ckgw90Vq4McIFksP0,9423
22
+ mobile_mcp_ai-2.3.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
23
+ mobile_mcp_ai-2.3.8.dist-info/entry_points.txt,sha256=KB_FglozgPHBprSM1vFbIzGyheFuHFmGanscRdMJ_8A,68
24
+ mobile_mcp_ai-2.3.8.dist-info/top_level.txt,sha256=lLm6YpbTv855Lbh8BIA0rPxhybIrvYUzMEk9OErHT94,11
25
+ mobile_mcp_ai-2.3.8.dist-info/RECORD,,