At this point you may get excited and would try to generate keypresses for other applications. This will not work. Android applications are allowed to generate keypresses only for themselves. In WindowManagerService class, you will find a permission check controlling this behaviour.
...
By default, WindowManagerService does not have this permission, that is why it is impossible to generate events for somebody else's window.