Hello,
I am attempting to write a bit of code in AppleScript to map the buttons on my Apple Remote to certain keys on my keyboard.
This is all I want:
(Remote = Keyboard)
left = Fn+F7
right = Fn+F9
play/pause= Fn+F8
(You might notice these are the media keys)
I am using an application from the app store call SofaControl for this, I know no other way (ControllerMate won’t give me general access to the Apple Remote).
The problem with SofaControl is that it seems to be application specific, which is annoying: I don’t want to be switching applications to play or pause a song on Spotify.
Advanced information
SofaControl gives you a few (what look to be) functions for assigning keys to buttons, here is an example of a preinstalled Spotify script:
(*
Copyright 2009, Kreisquadratur
Description: Minimal Spotify commands support (Spotify is still beta so there are not many commands to map)
Author: Uwe Dauernheim (uwe@dauernheim.net)
Product-URL: http://www.spotify.com/
Mappings:
* plus/minus: volume up/down
* left/right: switch to next/previous song
* play/stop: start/stop playing
*)
on rcActivate()
-- this code is executed when the script is activated
-- typically the target application gets activated
ignoring application responses
tell the application "Spotify" to activate
end ignoring
end rcActivate
on rcPlay()
-- send Space to Spotify
simulate keycode 49
end rcPlay
on rcLeft()
-- send Command-Left Arrow to Spotify
simulate keycode 123 with command
end rcLeft
on rcRight()
-- send Command-Right Arrow to Spotify
simulate keycode 124 with command
end rcRight
on rcPlus()
-- send Command-Up Arrow to Spotify
simulate keycode 126 with command
end rcPlus
If anyone can help, I’ll reiterate my simple requirments:
¢ I do NOT want this to be application-specific, I have disabled all other pre-installed scripts that came with SofaControl, so this should be the only one with access to the remote. (I want to control the media key from any space/desktop I’m on.)
¢ I just want the three afforementioned keys mapped, nothing else. I’m hoping this is as simple as:
(*for the play button*)
on rcPlay()
simulate keystroke "Fn"+"F8"
end rcPlay
. or something like that (don’t laugh, I don’t know AppleScript!!)
Hopefully it isn’t that complicated and someone can help. I’m only asking because I really don’t want to learn AppleScript just for the sake of doing this.
Model: MacBook Pro (Mid 2010); Operating System: Mac OSx 10.7
Browser: Safari 534.48.3
Operating System: Other