-
For example, I want a mouse move action based on the found image
Apparently, the above code doesn't work. I am wondering if there is any way may achieve what I expected? Thanks everyone. |
Beta Was this translation helpful? Give feedback.
Answered by
s1hofmann
Mar 28, 2022
Replies: 1 comment 2 replies
-
Late reply here, since I didn't check discussions regularly. One way to achieve your goal would be to use a Something like async function demo() {
try {
const targetRegion = await screen.find("image.png");
await mouse.move(straightTo(centerOf(targetRegion)));
} catch (e) {
await mouse.move(down(10));
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
s1hofmann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Late reply here, since I didn't check discussions regularly.
One way to achieve your goal would be to use a
catch
block.In case the image is not found, the
find
Promise will reject, thus you could move the mouse conditionally in this case.Something like