If you're like me, you're annoyed by macOS' unreliable media keys being handed over from iTunes or another media player to other applications without your control and sometimes bugging out entirely. If you're more like me, you alternate between iTunes and VLC all the time. And if you're even more like me, you'd like to have more reliable control over both without having to change the means of control when you switch.
Well you're in luck! Because I did that work for you. I wrote four short sets of scripts to control iTunes if VLC is not running and VLC and not iTunes if VLC is running (only play/pause and skip, but repeat/backwards can be easily added by analysing and replicating these scripts accordingly, I just never use that one.) with the Magic Mouse; you can also use these with the Trackpad by changing the trigger action (I do that myself on my MacBook Pro).
Half of those are written in the two Magic Mouse triggers in the uploaded preset, the other two you will have to copy & paste from the following script bits into an AppleScript file yourself (use the stock ScriptEditor app for this).
Steps to use (scroll down if you only need reliable iTunes controls):
Download the attached file: iTunes & VLC - Pause & Next.bttpreset (2.3 KB)
Open the Script Editor app (in your Utilities-folder, /Applications/ Utilities/ )
Create a new file containing this and save it as NextVLC.scpt in a folder of your choice (I created a folder called "bin" in my user category for these). This makes VLC play if it's currently paused and pause if it's currently playing (that function is often called "playpause" in settings and development):
tell application "VLC" to play
- Create a new file containing this and save it in the same folder, name it PlayVLC.scpt. This makes VLC skip the currently played media:
tell application "VLC" to next
Test-run the scripts with VLC running to test functionality. If this doesn't work, please comment so we can bugtrack.
Import the downloaded file to BetterTouchTool.
In the BTT configuration, edit both triggers' actions and change the AppleScript that's being run on activation to refer to the file path you saved your AppleScripts to (just change "xxxxx" to your username if you also created a folder called "bin" in your user-folder).
The trigger should now activate on 2-fixed-fingers TipTaps, Middle for Pause, Right for Next (I didn't use Left because normal Magic Mouse use leads to that TipTap being triggered all the time because the ring finger often registers as the Magic Mouse being touched there). You can change the gestures to something else you find more intuitive; if you use a trackpad, I recommend 2-fixed-fingers TipTaps with Left for Next and Middle for Pause.
Test-run each script to check functionality, then test-run each trigger to check functionality, both with VLC running and VLC not running. Note that since we're working with AppleScripts, line breaks are important and should be kept exactly the way they are already. To be sure: You need line breaks before every "if", "tell", "run" and "end if". The rest needs to stay in the same lines. Click "compile/test" in order to visually format the AppleScripts in BetterTouchTool (in ScriptEditor, this happens when running the scripts) and check for errors.
If it doesn't work, double-check the paths and names of your .scpt-files and wether the scripts inside of BetterTouchTool refer to these exactly. If it still doesn't work, please post here and describe the issue best you can so we can bugtrack, and mention especially wether the .scpt-scripts work by themselves if you run them by executing the files (or running them from the ScriptEditor app) but not through BetterTouchTool.
Needless to say, these triggers always only aim for iTunes and VLC and never YouTube, Vimeo or anything else. They can't break like the media keys do and always work as long as you execute the set gestures correctly. (I personally basically never use my media keys anymore and am very happy about it.)
You can also use these triggers for just reliable iTunes controls if you don't use VLC, in that case you can skip creating the script-files and should change the scripts BetterTouchTool executes to:
if application "iTunes" is running then
tell application "iTunes" to playpause
if application "iTunes" is running is running then
tell application "iTunes" to next track
I hope this works for everyone - I can't test this on current macOS system because hashtag poverty (my macs are both from 2011 and run only on High Sierra). If something doesn't work as expected, please post here and include the system you're running.
Feedback is appreciated!