Selecting external microphone

Is there a way using Applescript to set the “select a device for sound input:” of the sound panel from the System Preferences to use what ever external microphone the user plugs in?