在 OS X 中显示/隐藏特定应用程序的全局热键?

Rom*_*giy 10 hotkeys macos

可能的重复:
使用键盘快捷键启动 OS X 应用程序

是否可以定义全局热键来显示/隐藏 OS X 中的特定应用程序?

例如,我希望能够使用Cmd+显示/隐藏 Safari Space

Dan*_*eck 7

打开Automator,选择创建一个服务,配置让它在任何应用程序中没有输入

从库中,双击Utilities » Run AppleScript并在大文本区域中输入以下内容:

on run {input, parameters}

    tell application "System Events"
        set names to name of application processes
        if names contains "Safari" then
            tell application process "Safari"
                if visible then
                    set visible to false
                else
                    # use the following to simply have it reappear:
                    set visible to true
                    # use the following to focus Safari:
                    tell application "Safari" to activate
                end if
            end tell
        else
            display dialog "Safari is not running"
        end if
    end tell

    return input
end run
Run Code Online (Sandbox Code Playgroud)

以任何名称保存。在系统偏好设置»键盘»键盘快捷键»服务中分配键盘快捷。请记住禁用 Spotlight 快捷方式Cmd-Space

  • 如果它没有运行,您可以替代“显示对话框”,或者“告诉应用程序“Safari”激活”以启动它。 (2认同)

归档时间:

查看次数:

4191 次

最近记录:

13 年,3 月 前