Send Keystroke to Keynote App in Background but NOT App With Focus

I’m using a macro that sends the right arrow key to Keynote using the “Type a Keystroke” action. This enables me to advance to the next Keynote slide even if Keynote isn't the foreground application. However, it also insists on sending this same keystroke to whatever application has the focus.

To be clear, I want to send the keystroke to Keynote in the background but not send the keystroke to the app that currently has the focus. Is this possible?

Instead of sending a keystroke, send the menu command. As long as this Macro is in an active group it will work even if Keynote if not the foreground app. (The slideshow needs to be in a Window rather than fullscreen - but that would be the case if another app is in the foreground.)

EXAMPLE Keynote Advance to Next Slide.kmmacros (2.6 KB)

Click to Show Image of Macro

That's was what I was doing previously. However, it didn’t work reliably. Also, it doesn't advance to the next build but to the next slide. The right arrow key advances to the next build. Thanks.

Try this:

EXAMPLE Keynote Advance to Next Build.kmmacros (2.7 KB)

Click to Show Image of Macro

tell application "Keynote"
  show next
end tell

show next

show next (verb)Advance one build or slide.

1 Like

That works beautifully; however, it still passes the keystroke to the foreground app. Thanks.

Hello, @michaelhyatt could you use another trigger key for the macro that @Zabobon send you ?

In this case other apps will not trigger but only keynote in background.

Unfortunately, I can't. I can't program the keys on the remote.

@peternlewis, is it possible to keep KM from passing the keystroke to the foregound app?

1 Like

The Type a Keystroke action, when you use the Send To option, sends the keystroke only to that application. It does not send it to the front application.

I just double checked and verified this with the Right Arrow sent while in a Mail message to BBEdit, and it works as expected, so I suspect something else is going on for you.

Hang on, if you are using the AppleScript, and that works, then where is the keystroke coming from?

2 Likes

I'm using the Keynote Easty Presenter remote. Here's what the macro looks like. It’s sending a right arrow key keystroke.

Maybe what we need is an option not to pass through the keystroke generated by the device itself. Another option would be a toggle that would allow the user to choose whether or not to pass the keystroke through.

The USB Device Key trigger detects buttons, it does not swallow them. It has no ability to swallow them.

Use a Hot Key trigger, which will swallow the key (but cannot differentiate between keyboards).

2 Likes