PURPOSE
This macro/subroutine, when executed from another macro using the Execute a Macro action, sets the Macintosh Sound Input to a specified name. This can include Apple HomePods and other AirPlay devices. Note that this shortcut uses AppleScript that automates the User Interface, specifically the System Preferences (Monterey or earlier) or System Settings (Ventura+). See Automating the User Interface (Mac Automation Scripting Guide: Automating the User Interface) for more information.
If this subroutine is called using Execute a Subroutine action, additional features are provided that can be useful if the macro is combined with Set Sound Output. See PARAMETERS below.
SUBROUTINE PARAMETERS
Sound Input Name :
Note that any spaces and punctuation marks must exactly match the entries in the System Preferences (or System Settings) > Sound > Output. For example, Jim’s AirPods Pro includes a smart apostrophe ( ’ ).
Save Initial State :
0 (No); 1 (Yes)
This saves, in a persistent Dictionary, the Open|Closed state and, if Open, the Displayed Pane. This value can then be retrieved by another instance of Set Sound Input (SSI) or the sister macro Set Sound Output (SSO).
Exit Action :
0 (Initial State, i.e., the state when SSI started; i.e., Open|Closed, if Open, which Displayed Pane)
1 (Saved State, i.e., the state saved in the Dictionary by SSI or SSO)
2 (Open–to the Sound pane)
3 (Close)
This value specifies the action to be taken with the System Preferences (or System Settings) after the Sound Input is set.
CREATING A CALLING MACRO
If the macro is executed directly (e.g., from the Keyboard Maestro Editor), a dialog will appear that presents an option to create a calling macro. The dialog will prompt for the Sound Input Name. Note that any spaces and punctuation marks must exactly match the entries in the System Preferences (or System Settings) > Sound > Input. For example, Jim’s AirPods Pro includes a smart apostrophe ( ’ ).
If the Call As a Subroutine dialog checkbox is selected, the created macro will have the flexibility to use the SUBROUTINE PARAMETERS described above.
LOCALIZATION
By default, the AppleScript User Interface Scripting is set for English. If another Language is set under System Preferences (or System Settings) Language & Region, the variable local_Pane needs to be set to Sound|Geluid|Ton (English, Nederlands, or Deutsch). Other languages could be easily added.
LIMITATIONS
This macro requires Keyboard Maestro v10.0+.
TESTED WITH
• Keyboard Maestro 10.2
• Ventura 13.3.1 (22E772610a)/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
( expand / collapse )
1.0 - Initial version; compatible with Set Sound Output, v6.0 or later. For more information see: Using 'Set Sound Output' and 'Set Sound Input' Together
2.0
a) Support for macOS 14 (Sonoma): new AppleScript UI script compatible with Sonoma (slightly different than Ventura).
b) For the local__Exit Action 0I 1S 2O 3C = 2 condition, removed the Cancel Just This Macro action as I discovered that this does not function as expected when used within a subroutine. This action might be changed in a future version of Keyboard Maestro (reference).
2.1
a) In one of the If Then Else actions "Sound" was hardcoded. This has been changed to local_Pane to properly accommodate the macro localization.
b) For some unknown reason, with Sonoma 14.2.1 (23C71), the gui hierarchy can differ on some some macs; the AppleScript within this macro now accommodates both. For more information, see: Why would UI scripting vary on two Macs with the same version of macOS? - AppleScript - Late Night Software Ltd. This issue was actually discovered and reported by @OneEyedJack for the sister macro Set Sound Output.
c) For all of the AppleScripts, to improve performance, changed fixed delays to 'repeat until exists'.
d) For Ventura and Sonoma AppleScripts, changed 'starts with' to "is' when checking for a matching Sound Input.
e) Deleted some disabled groups that had mistakenly been retained.
If upgrading from an earlier version of Set Sound Inout, please read the following before downloading:
From within the Keyboard Maestro Editor, delete your existing copy of Set Sound Input before you download and install the new version. On the other hand, do not delete your calling macros.
Download: Set Sound Input.kmmacros (171 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 14.2.1 (23C71)
- Keyboard Maestro v11.0.2