在指定坐标点击 @param x X坐标 @param y Y坐标 @throws Exception 点击失败时抛出异常
(int x, int y)
| 491 | * @throws Exception 点击失败时抛出异常 |
| 492 | */ |
| 493 | public static void u2Click(int x, int y) throws Exception { |
| 494 | Log.d("monitoru2", "点击坐标: (" + x + ", " + y + ")"); |
| 495 | |
| 496 | try { |
| 497 | MyAccessibilityService service = MyAccessibilityService.getInstance(); |
| 498 | if (service != null) { |
| 499 | Log.d("monitoru2", "无障碍服务实例获取成功,准备执行点击"); |
| 500 | boolean success = service.clickOnScreen((float)x, (float)y); |
| 501 | if (success) { |
| 502 | Log.d("monitoru2", "点击成功: (" + x + ", " + y + ")"); |
| 503 | } else { |
| 504 | Log.e("monitoru2", "点击失败: 无障碍服务clickOnScreen返回false"); |
| 505 | throw new Exception("无障碍服务点击失败"); |
| 506 | } |
| 507 | } else { |
| 508 | Log.e("monitoru2", "无障碍服务实例为null,服务可能未启用"); |
| 509 | throw new Exception("无障碍服务未启用"); |
| 510 | } |
| 511 | } catch (Exception e) { |
| 512 | Log.e("monitoru2", "点击操作异常: " + e.getMessage()); |
| 513 | throw new Exception("点击失败: " + e.getMessage()); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | |
| 518 |
no test coverage detected