修复recognizeTextAndClick函数偶发识别异常的问题 (#1036)
由于点击的坐标是根据OCR坐标计算出来的,如果click的参数x和y一个是整数,一个是浮点,会报错`Invalid argument specified for parameter 'arg1'` 需要取消catch才能看到报错,不然会被catch而当做找不到文字掩盖
This commit is contained in:
@@ -46,8 +46,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(`识别到目标文本: ${correctedText},点击坐标: x=${centerX}, y=${centerY}`);
|
||||
await click(centerX, centerY);
|
||||
await sleep(500); // 确保点击后有足够的时间等待
|
||||
|
||||
Reference in New Issue
Block a user