修复recognizeTextAndClick函数偶发识别异常的问题 (#1036)
由于点击的坐标是根据OCR坐标计算出来的,如果click的参数x和y一个是整数,一个是浮点,会报错`Invalid argument specified for parameter 'arg1'` 需要取消catch才能看到报错,不然会被catch而当做找不到文字掩盖
This commit is contained in:
@@ -79,8 +79,8 @@ async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
|
||||
|
||||
if (correctedText.includes(targetText)) {
|
||||
// 如果找到目标文本,计算并点击文字的中心坐标
|
||||
let centerX = res.x + res.width / 2;
|
||||
let centerY = res.y + res.height / 2;
|
||||
let centerX = Math.round(res.x + res.width / 2);
|
||||
let centerY = Math.round(res.y + res.height / 2);
|
||||
log.info(`通过 OCR 识别找到文字: ${targetText}`);
|
||||
log.info(`中心坐标: x=${centerX}, y=${centerY}`);
|
||||
await click(centerX, centerY); // 执行点击操作
|
||||
|
||||
Reference in New Issue
Block a user