答案1
打开自动机,选择创建一个服务,配置让它接收没有输入在任何应用程序。
在库中双击实用程序 » 运行 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
。
答案2
在 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
- 如果目标应用程序当前位于最前面,则隐藏它
- 否则激活它
答案3
CMD+W 将隐藏窗口。此功能全局有效。但是要返回窗口,您需要单击停靠图标。但在浏览器中,它将关闭选项卡。