I have 3 open VLC windows and whenever I see movement in one I need to pause all of them at once. Ideally I'd like a keyboard shortcut to do this. I tried AppleScript but I'm not familiar with the language and I can't see how to iterate through all processes of an application and tell each one individually.
This will check for all instances of VLC and pause any of the instances that are currently playing something. Let me know if something unexpected happens! To create the shortcut, follow these steps:
Open Automator and create an Service, with a single Run AppleScript action, containing the following code:
tell application "System Events" to repeat with VLC_instance in (application processes whose name is "VLC") tell the menu "Playback" of the first menu bar of VLC_instance if the menu item "Pause" exists then click menu item "Pause" else if the menu item "Play" exists then click menu item "Play" end if end tell end repeat
Set the service to receive "no input" and to work in "VLC" or "any application", if you want to ensure you can use the shortcut from anywhere. Save it with a name of your choosing.
- Now, go into the Shortcuts tab in the Keyboard preferences in System Preferences, and click on Services. The newly created service should be at the bottom, under the name you chose. Click on the service, then click on "add shortcut", and specify a shortcut to your liking.
- You may have to allow Automator access in Accessibility in the Privacy tab of the Security and Privacy preferences.
That's it! You should now have a service set up, tied to the shortcut you chose that can be accessed from anywhere.