More > JRiver Media Center 24 for Mac

Mac Media Keys Fix

(1/2) > >>

dfortney:
Would it be possible for you guys to run this apple script right after launch on a Mac or possibly a way to run any external app or script on launch?  This script fixes the issue with Media Center not grabbing the media keys on launch and just toggles the 'Use F1 keys...' option under Keyboard preferences on and off again.

tell application "System Preferences"
   reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell

tell application "System Events" to tell process "System Preferences"
   repeat until exists tab group 1 of window 1
   end repeat
   click checkbox 1 of tab group 1 of window 1
   delay 1
   click checkbox 1 of tab group 1 of window 1
end tell

quit application "System Preferences"

dfortney:
actually I just added a call to launch media center before running the f key toggle.  so anyone having this issue just create this as an app in script editor and run it to launch media center instead of the media center app itself...

tell application "Media Center 24" to activate

delay 1

tell application "System Preferences"
   reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell

tell application "System Events" to tell process "System Preferences"
   repeat until exists tab group 1 of window 1
   end repeat
   click checkbox 1 of tab group 1 of window 1
   delay 1
   click checkbox 1 of tab group 1 of window 1
end tell

quit application "System Preferences"

blgentry:
I was doing some research about this because I was curious about using a "defaults write" command instead of having to "hack" using AppleScript which relies upon the layout of the preferences pane.  Imagine my surprise when I found this application that automatically switches your F key preferences based on what program you are running!

https://github.com/Pyroh/Fluor

I have not used it, installed it, or tested it.  I just found it and thought dfortney or others might find it useful.

Brian.

dfortney:
I found it too and used it but it doesn't do what is actually needed in this case.  See it isn't a problem of having the right setting under keyboard prefs (unchecked) but that after launching media center even when it is unchecked you must check it and once again uncheck it to get it to register properly.  I think it must be a callback that isn't happening on launch from the os to tell media center (or any app perhaps) what the setting actually is.  I believe this applescript is the only way to fix this unless media center takes it internally to execute on their own during launch but of course using more appropriate API instead of hacking it as such.

dfortney:
oh one thing I forgot to mention above is after you save this apple script as an 'application' you must go to system pref -> security -> privacy -> accessibility and unlock for changes and then + to add this new app to the list of allowed apps.  what I did was remove the original media center icon from the dock and instead keep this application locked to the dock and before saving it in script editor you can actually steal the original media center icon file from within their package ->resources folder and drop it into the package within the editor so it looks like the original app icon.

Navigation

[0] Message Index

[#] Next page

Go to full version