How to find a button's XY coordinates on screen and click at it?

I need to find a button's XY coordinates on screen using this button's image and then click at it. I can do this task on windows using AutoHotKey Image search. And I found out that ubuntu AutoHotKey alternative is AutoKey. But I couldn't find a way to do an image search on AutoKey. Does anybody know how to achieve this task?

1 Answer

You can obtain the current mouse coordinates with xdotool:

xdotool getmouselocation

For use in a script, use

eval $(xdotool getmouselocation --shell)

This will create shell variables you can easily retrieve elsewhere in a script:

echo $X $Y

will print the coordinated.

Caveat this only works when you use Xorg (but then, also Autokey works only on Xorg).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like