Is it possible to create shortcuts for VLC using Automator

applescriptautomatorkeyboardvlc

I see here that Automator can be used to create commands that then can be triggered globally.

I have no idea how to use Automator but see that it has some options for involving applications… Can a "service" be created for VLC that will then be bound to keystroke triggers?

What I want are simple commands like pause/play, back and forward that could be used with shortcuts no matter what other window application is on top.

Best Answer

You can create services like this:

Then give the services shortcuts from System Preferences > Keyboard > Shortcuts > Services.

I prefer using third party applications instead of services to assign shortcuts to scripts though. There has been a bug since 10.7 where the shortcuts for services don't always work until you hover over the services menu from the menu bar (or for example run a service once from the menu bar). There is also a noticeable delay before services are run, and the shortcuts for services don't work when an application that doesn't have a services menu (like Tower) is frontmost.

More examples:

tell application "VLC"
    if playing then
        tell application "System Events" to tell process "VLC"
            click menu item "Pause" of menu 1 of menu bar item "Playback" of menu bar 1
        end tell
    else
        play
    end if
end tell
tell application "VLC"
    set n to 60
    if duration of current item - current time > n then
        set current time to current time + n
    else
        next
    end if
end tell
tell application "VLC"
    set fullscreen mode to not fullscreen mode
end tell
tell application "VLC"
    volumeUp
end tell

Open VLC's dictionary in AppleScript Editor to see all supported terminology.