Advertisement
wch1zpink

Toggle Fn Keys

Mar 13th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if application "System Preferences" is running then ¬
  2.     do shell script "killall 'System Preferences'"
  3. repeat until application "System Preferences" is not running
  4.     delay 0.1
  5. end repeat
  6.  
  7. (* Here is an example of why I needed to use
  8. do shell script "killall 'System Preferences'" instead of tell application "System Preferences" to quit…
  9. Which won’t work if this "System Preferences" panel and sub menu were open.
  10.  
  11. https://i.imgur.com/JnIwUur.png  *)
  12.  
  13. tell application "System Preferences"
  14.     reveal anchor "keyboardTab" of ¬
  15.         pane id "com.apple.preference.keyboard"
  16. end tell
  17. tell application "System Events"
  18.     repeat while not (exists of pop up button 2 of tab group 1 ¬
  19.         of window "Keyboard" of application process "System Preferences")
  20.         delay 0.1
  21.     end repeat
  22.     perform action "AXShowMenu" of pop up button 2 of tab group 1 ¬
  23.         of window "Keyboard" of application process "System Preferences"
  24.     repeat while not (exists of menu item "F1, F2, etc. Keys" of menu 1 ¬
  25.         of pop up button 2 of tab group 1 of window ¬
  26.         "Keyboard" of application process "System Preferences")
  27.         delay 0.1
  28.     end repeat
  29.     click menu item "F1, F2, etc. Keys" of menu 1 of pop up button 2 ¬
  30.         of tab group 1 of window ¬
  31.         "Keyboard" of application process "System Preferences"
  32. end tell
  33. tell application "System Preferences" to quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement