Autokey does not work well with wayland, which is the default display server on ubuntu 21.04 and presumably all newer releases. Not sure what the exact process is for switching back to the X11 window manager but I suspect doing so will solve the issue.
At the login screen look around for a setting that allows you to select the session to login, according to this website there should be a "Ubuntu" and a "Ubuntu on Wayland", select the former and you should be good to go.
The reason some apps work but not all is because wayland or maybe ubuntu itself will run some apps in some way that makes them X11 accessible.