相关超级用户-启动的OS X应用程序使用键盘快捷键。我对该问题的答案进行了编辑,以包含支持显示或隐藏样式触发器的第三方应用程序。我还添加了一个AppleScript用于显示或隐藏应用程序。
—
Lri 2011年
Answers:
打开Automator,选择创建服务,将其配置为在任何应用程序中不接收任何输入。
在库中,双击实用程序»运行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
用任何名称保存。在系统偏好设置»键盘»键盘快捷方式»服务中分配键盘快捷方式。请记住禁用Spotlight快捷方式Cmd-Space
。
display dialog
,你可以替换tell application "Safari" to activate
,如果它没有运行启动它。
在AppleScript编辑器中保存并分配在OS X中运行脚本的快捷方式
tell application (path to frontmost application as text)
if name is "TextEdit" then
set bid to id
tell application "System Events" to tell (process 1 where bundle identifier is bid)
set visible to false
end tell
else
tell application "TextEdit"
reopen
activate
end tell
end if
end tell
CMD + W将隐藏窗口。这在全球范围内有效。但是,要回到他们身边,您需要单击扩展坞图标。但是,在浏览器中,它将关闭选项卡。