Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AppleScript - Switch to hardware mic
-- Force mac book pro 10.13.3 to switch audio input to hardware mic
tell application "System Preferences" to activate
tell application "System Preferences"
reveal anchor "input" of pane id "com.apple.preference.sound"
end tell
tell application "System Events" to tell process "System Preferences"
select (row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound" whose value of text field 1 is "Internal Microphone")
end tell
quit application "System Preferences"
@dotjay
Copy link

dotjay commented Jun 24, 2021

Thanks for the script! To get it work in 2021, I had to add a delay 1 before the select command.

@mustafapc19
Copy link

mustafapc19 commented Jul 23, 2021

Hi. I am new to the apple ecosystem. How should I go about using this script? I am using Script editor and running from there is working but if I switch the sound output source the input source gets changed to my airpods. Any help would had been appreciated

@lfender6445
Copy link
Author

lfender6445 commented Jul 23, 2021

@mustafc you need a way too run apple scripts (save it as a .scpt file first)

have a read through https://www.techradar.com/how-to/computing/apple/terminal-101-running-applescripts-from-the-terminal-1305736

@mustafapc19
Copy link

mustafapc19 commented Jul 24, 2021

@lfender6445 Thanks for the help. I used FastScript and mapped a keyboard shortcut to the script. Otherwise, it's a big pain since every time I pair the airpods I have to do it again. Thanks for the help tho :)

@crisdeoliveira
Copy link

crisdeoliveira commented Oct 2, 2021

i have this error when i run, any ideas?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment