Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
Sign in to follow this  

Selective Play/Pause for VLC and iTunes with AppleScript

1 post in this topic

Recommended Posts

I have 5 button mouse, and i currently using one button for play/pause the music in iTunes (with USB Overdrive app). But sometimes i'm using VLC (i don't want scre up my music library with lot of s*it), and because i can assign AppleScript to the mousebuttons in USB Overdrive, i want to write an script wich checking wich program running currently. If iTunes, then it will tell play/pause to iTunes, but when VLC running it will tell to play/pause to VLC.


Here is the working code:


on run {input, parameters}
 return input
end run

on idle	
set x to isAppLoaded("VLC")
 if x then tell application "VLC" to play --valid parameters: play, next, previous
if set x to isAppLoaded("iTunes")	
 if x then tell application "iTunes" to playpause --valid parameters: playpause, next, previous
end if
end idle

on isAppLoaded(app_name)	
tell application "System Events"
set app_list to every application process whose name is app_name
if the (count of app_list) > 0 
then set x to true		
else set x to false		
end if	
end tell	
return x
end isAppLoaded


Save the 3 script (play-pause, next, previous) as application, and assign it to the mouse buttons with USB Overdrive.


Have fun!


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.