Almost all applications will ignore synthetic events for security reasons, so the effective answer is no, this is not possible. If you want to control an application that doesn’t have focus, see if it has a socket (or maybe dbus) you can send messages to.