Sending keystrokes to a non-activate application?

Hi, I was wondering if anyone could tell me if the following is possible in Applescript.

I have two applications running, and I’d like to be able to send keyboard input to the non-active one without having to activate it.

In an absolute best case scenario, it would be great if I could simply hold one key down on the keyboard and then all keyboard input would be routed to the non-active app as it was typed, and would revert to normal upon releasing the key.

Next to that, since it will be a single keystroke at a time for the most part to basically enter commands, from a limited set of keys, I could have a separate script mapped to each key and that would be fine. It would only be a few of the keys on the numpad, and I could easily use QuicKeys or another similar app to have it activate an Applescript for each numpad key while the main application is open.

In either case, the optimal thing would be not having to change focus to the secondary application. Right now I have a very simple script set up to activate the background app, send a keystroke, and then re-activate the main app, and that works well enough, it just switches it for a tiny fraction of a second. But if I’m going to be doing this a lot, I can see how it would get annoying over time and was wondering if it was possible to send the input without switching focus like that. The application doesn’t have any Applescript support in it, either, so I’d have to do so using only basic events.

Is this possible, or should I just stick to using activate? Thanks.

I don’t think you can. You can send keystrokes using System Events, but they go to the front application, even if you try to say:

tell application process "Safari to keystroke "h" using command down

If anyone else finds a way to do this, I’m sure they will post it!