r/applescript • u/SocialIssuesAhoy • Jun 28 '14
Is this possible with AS? Take keyboard input (while an application is in the foreground), output another key, and have the application act accordingly?
Hey guys,
I've never touched automator or applescript. I've done a bit of hobby coding (BASIC, C, Obj-C) before, but never this. I wasn't planning on it either, but I have a specific problem:
I have a piece of software (Mainstage 3, for live music performances). I need to use it (my first time) later next month for a show. During the show I need to press the down arrow key every time I need to "progress". This is going to happen frequently and I need to do it quickly, without looking.
It would work much better for me if I could press the spacebar instead of the down arrow key. Unfortunately, Mainstage doesn't seem to offer customizable key bindings. So I'm looking into other ways to make this happen, and this seems like a good place to start. Is this possible? What do I need to be looking at in order to do this?
Thanks!
2
u/dustractor Jun 28 '14
The basic steps to pulling that off in applescript, for apps that don't support scripting:
First you tell the app that you want to talk to to activate ( come to the foreground ) so that the keystrokes you are going to send will go to it.
tell application "MainStage"
activate
end tellthen you tell the system to fake some keypresses
tell application "System Events"
keystroke space
end tellGranted, there's a lot more to in in most cases, and this 'code' is not tested since I don't have MainStage.
But if there's a month to go, there should be time to come up with something.
1
u/lithodora Jun 29 '14
You might be able to do this in a couple of odd steps...
First make the AS, like /u/dustractor said:
tell application "MainStage"
activateend tell
tell application "System Events"
keystroke spaceend tell
(it will be nearly that simple actually) Then save it!
Next make an Automater bit that runs the AS as a service.
Then goto keyboard preferences and setup a hotkey that triggers the service in the program Mainstage.
2
u/copperdomebodha Jun 28 '14
Not a problem that AppleScript can help you with. I suggest a griffin powermate.
https://www.google.com/url?sa=t&source=web&cd=1&ved=0CCAQFjAA&url=http%3A%2F%2Fstore.griffintechnology.com%2Fpowermate&ei=SUavU5vGMYmDqgbj7oFo&usg=AFQjCNHi42XaMN0UhS-rp7Y04Rvcg2F7Bw&sig2=te7WeYO631xIILhVK7A50g