4

I am creating android remote controller for mac and for simplicity I want the same behavior in my app like behave standard multimedia keys on mac (F7, F8, F9).

I have installed "Key Codes" app on my mac but it doesn't recognized multimedia keys.
I have googled that keycode for playpause button is 100, so I have tried this lines of code from terminal:

osascript -e 'tell application "System Events" to key code {100}'

osascript -e 'tell application "System Events" to keystroke 100'

But it doesn't work.

What is the best approach to achieve the same behavior like multimedia keys do from osascript?
In all macs the same multimedia keys do the same behavior?

Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127
jakub
  • 3,576
  • 3
  • 29
  • 55

1 Answers1

1

Key code 100 is actually F8, it's the same key, but a different command.

Unfortunately, it seems the only way to run the play, pause, next, previous command in media players via applescript is to send the proper key directly to the application. Typically under the controls/playback menu (i.e. iTunes and Spotify )

iTunes and Spotify can also be told "back track", "next track","playpause", "play", and "pause" to control the music via applescript. see: https://gist.github.com/NoobsArePeople2/5121597

Luke Rehmann
  • 514
  • 5
  • 12