Send Key to Specific Window

Hi there! I would love the ability to send a keystroke to a specific window (ie application) WITHOUT activating it. In other words, I have, for example, PowerPoint, running behind my current application and I would like to advance the slides without bringing PP to the front. Anyone tried this?

I think the only way that would be possible would be if PowerPoint had AppleScript support to advance slides.

And even then I'm not sure it would be possible.

1 Like

That might be possible. The Type a Keystroke action supports sending to a specific app in the background using the "Send To" option in the Gear Menu:



That's IT!

Well shuck my corn… I never knew that was there.

Excellent tip! That may come in handy, for sure.


No problem. KM has so many Actions, Tokens, and Functions now that no one can remember or have found all of them. :wink:

1 Like

Just for posterity, there's a simple AppleScript solution for the PowerPoint use case (though the presentation does have to be in slide show view first):

tell application "Microsoft PowerPoint"
	go to next slide slide show view of slide show window 1
end tell
1 Like

I am with you on this one....... the cogwheel has many dark secrets no-one but the High Priests know about.

I’m now going to “have to” update all of my Stream Deck macros that control Zoom to take advantage of this feature without bringing Zoom forward, which will be quite useful.


Curious… I was able to get this to work in BBEdit without any issues, but whenever I try to send a keystroke (⌘T) to Audio Hijack, I just get a system error beep.

Not sure if this is a Keyboard Maestro bug or a limitation of something about the way that AH was designed.

Paging @peternlewis ! Do you want me to send an email with this as a potential bug report? What's easiest for you to track/followup?

Thanks! Are you a bit of an AppleScript pro? I actually figured this out for PowerPoint finally but when I attempt the same thing for Keynote, I get an error. Turns out that Keynote requires the window to be active to use the "show next" action. So the answer, for keynote anyway, would be to send keystrokes to the window or process but I'm completely failing at this. Got any idea how to send Fn+Down, for example, to Keynote, while it's in the background?

I doubt it is KM bug, since it works in a lot of other apps.
Most likely it is due to the design of AH.

When creating a simulated event, you can specify targeting at a specific pid. The only plausible Keyboard Maestro issue is getting the right pid for Audio Hijack - if Audio Hijack has multiple different processes for example, then maybe it is going to the wrong one.

Applications do not generally expect to receive events while in the background, so they don't always behave as desired. But getting a system beep is a typical case of "no one is listening" - Audio Hijack would have to have some sort of text field or whatever for this keystroke to go in to, otherwise it'd be the same as typing in a Mac app when no one is listening and you get a beep in response.

1 Like

As a workaround, you can use this technique which I have successfully used in the past:

  1. Activate AH
  2. Pause until AH is frontmost
  3. Type the keystroke (Use Select Menu instead if available)
  4. Activate Previous app (or Hide AH).

IME, all I see is a very, very brief flash on the screen.

I checked and Audio Hijack does have an "Audio Hijack Scheduler" process, but I quit that, and the system beep still happened.

Well, what I really want to do is send ⌘T to 'Split' a recording, but that keyboard shortcut is only active when a recording is active, obviously.

So I tried ⌘R instead, which is "Stop Session" if one is running and "Start Session" if one is not:

I still get the system beep, and AH does not react as if ⌘R has been received.

There is a demo version of Audio Hijack available if you want to check it out for yourself. I don't think there is anything weird in my setup which would cause this. I would assume that the Rogue Amoeba developers are doing things in a fairly typical macOS style, but there's always the edge case.

Yup, that's exactly what I've been doing, except that I have an 'if/else' for "Is Audio Hijack frontmost?" at the beginning of the macro so if it is, Keyboard Maestro will not activate a different application after the macro is over.

So it's ~6 steps or so. Not too overly complicated, but being able to change it to one step "Send Keystroke to Audio Hijack" would be preferable, obviously, especially because I have a number of these for AH.

It may be that the menus are not ready to accept the command keys (maybe it does not enable the menus when the app is not at the front).

I'm afraid you might be out of luck in that case. You could, presumably, use the Select a Menu Item action.

Will opening the recording module and set a file size limit work?

I was wondering if it would be a good idea have an action to tell KM not to display the screen for say 0.8 secs whilst it does a "background macro"
along the lines of turn display update off for xxx millisecs?

I don't think so. It would probably break this workflow. The "flash" is the target app coming to the front, allowing its internal code turning on receptors to input, that make this workflow work.