Using applescript to control an application which does not support it

applescript

I want to control an application that does not have an Applescript api (simfy). I would like to pause it via an Alfred command, but for this I need to use scripts. This application is build with Adobe Air and there is no script dictionary entry for it.

I have created some shortcuts via System Preferences, but I would like to access the options even when I am using another program. The typical use case, is that I am working in my editor, I want to switch to the next song without having to leave it.

Do you know how to script an application without applescript support?

Best Answer

The only way I am aware of is using UI Scripting (old link but still useful) via the dictionary of an application called "System Events". In substance, this allow you to make a script that click on a given button or press a given key. Unfortunately, you'll need to activate Simfy to send the keystroke (but you can automate it and automate a switch to the preceding frontmost application as well).

Remote Buddy allow you to send a keystroke to an application without activating it. You can then trigger the Remote Buddy action via AppleScript. But that seems overkill here except if you use Remote Buddy for other things already.