Send a key code to an application without activating it first?

I don’t think you can send a keystroke to an inactive application.

But you can hide an app immediately after activating it and executing code for it. This does however, cause the app to briefly flash before it hides, unless the app is running in fullscreen.

tell application "System Events"
    tell application "X" to activate
    key code 49
    set visible of process "X" to false
end tell

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)