使 Mac 媒体键打开 iTunes 以外的应用程序

Wuf*_*ers 19 media-keys macos

在 Mac 上,当按下“按下/播放”媒体键 ( F8) 并且没有应用程序拦截该键时,它会打开 iTunes 并开始播放。有没有办法让它打开另一个应用程序?就我而言,我希望它打开 Spotify。如果有可能让它在发布时开始播放(也许 AppleScript 是实现此目的的方法?)

小智 5

我知道这个问题很老,但其他答案并不能真正解决问题。

您所要做的就是安装Karabiner(以前称为KeyRemap4MacBook

然后你只需要添加想要的行为。

  • 打开Preferences菜单。
  • 切换到Misc & Uninstall选项卡
  • 点击 Open private.xml
  • private.xml在您喜欢的文本编辑器中打开文件
  • 用这个定义替换空文件:

    <?xml version="1.0"?>
    <root>
        <!-- Spotify Path -->
        <vkopenurldef>
            <name>KeyCode::VK_OPEN_URL_APP_Spotify</name>
            <url type="file">/Applications/Spotify.app</url>
        </vkopenurldef>
    
        <!-- Set Spotify definition -->
        <appdef>
            <appname>SPOTIFY</appname>
            <equal>com.spotify.client</equal>
        </appdef>
    
        <!-- Use 'Music Play' key to launch Spotify if not ever in the application -->
        <!-- else, act as normal play/pause button in Spotify, Itunes -->
        <item>
            <name>Change Play key to launch Spotify</name>
            <identifier>private.play_launch_spotify</identifier>
            <not>SPOTIFY, ITUNES</not>
            <autogen>
                __KeyToKey__,
                ConsumerKeyCode::MUSIC_PLAY,
                KeyCode::VK_OPEN_URL_APP_Spotify,
            </autogen>
        </item>
    </root>
    
    Run Code Online (Sandbox Code Playgroud)
  • 返回Change Key选项卡并单击Reload XML按钮。

  • 您现在只需启用添加在列表顶部的新项目:

    截屏

  • 我如何使用 [Karabiner Elements](https://pqrs.org/osx/karabiner/)(原始的 Karabiner 必须为较新版本的 macOS 报废,取而代之的是 Karabiner Elements)?也许我可以通过向 `.config/karabiner/karabiner.json` 文件添加条目来指定 [复杂修改](https://pqrs.org/osx/karabiner/complex_modifications/)? (2认同)

tek*_*agi 2

您可能会发现这也很有用。如何防止 iTunes 在按下媒体键时启动

Spotify 应默认响应 F8。如何获得精美的key图标?

  • 您所要做的就是用 &lt;kb&gt; HTML 标签将您想要制作的图标包围起来。 (4认同)