Advertisement
Guest User

Audio-Device-Switch

a guest
Jan 13th, 2022
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. — Zustand von Systemeinstellungen sichern
  2. set sysPrefsWasRunningBefore to application „System Preferences“ is running
  3. if sysPrefsWasRunningBefore then
  4. tell application „System Preferences“ to set prevSysPrefPane to current pane
  5. else
  6. tell application „System Preferences“ to run
  7. end if
  8. — Soundeinstellungen aufrufen
  9. tell application „System Preferences“ to set current pane to pane „com.apple.preference.sound“
  10. — Auswahlfenster zeigen
  11. display dialog „Sounddevice“ buttons {„Headset“, „iMac“} default button 1 with icon 2
  12. — wenn „Headset“ gewählt wurde, dann diese Schleife
  13. if button returned of result is „Headset“ then
  14. tell application „System Events“ to tell application process „System Preferences“
  15. tell window 1 to tell tab group 1
  16. delay 1
  17. click radio button „Ausgabe“
  18. tell table 1 of scroll area 1
  19. select row 2
  20. end tell
  21. end tell
  22. end tell
  23. delay 1
  24. tell application „System Events“ to tell application process „System Preferences“
  25. tell window 1 to tell tab group 1
  26. delay 1
  27. click radio button „Eingabe“
  28. tell table 1 of scroll area 1
  29. select row 2
  30. end tell
  31. end tell
  32. end tell
  33. — Ende der Schleife wenn „Headset“ gewählt wurde
  34. else if button returned of result is „iMac“ then
  35. — wenn „iMac“ gewählt wurde, dann diese Schleife
  36. tell application „System Events“ to tell application process „System Preferences“
  37. tell window 1 to tell tab group 1
  38. delay 1
  39. click radio button „Ausgabe“
  40. tell table 1 of scroll area 1
  41. select row 1
  42. end tell
  43. end tell
  44. end tell
  45. delay 1
  46. tell application „System Events“ to tell application process „System Preferences“
  47. tell window 1 to tell tab group 1
  48. delay 1
  49. click radio button „Eingabe“
  50. tell table 1 of scroll area 1
  51. select row 1
  52. end tell
  53. end tell
  54. end tell
  55. — Ende der Schleife wenn „iMac“ gewählt wurde
  56. end if
  57. — Zustand von Systemeinstellungen wiederherstellen wie vorher
  58. if sysPrefsWasRunningBefore then
  59. try
  60. tell application „System Preferences“ to set current pane to prevSysPrefPane
  61. end try
  62. else
  63. tell application „System Preferences“ to quit
  64. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement