Jump to content

Selective Play/Pause for VLC and iTunes with AppleScript

  • Please log in to reply
No replies to this topic



    InsanelyMac Geek

  • Members
  • PipPipPip
  • 107 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!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy