【发布时间】:2015-03-11 21:37:31
【问题描述】:
这看起来很简单。 "if (frontApp = "Safari") then" 做 Safari 部分。如果不是,则执行 else if 部分“else if (frontApp = "Google Chrome") then"
当我打开 Chrome 并运行此脚本(在 Automator 工作流程中)时,它会正常运行 Chrome 部分,然后继续打开 Safari。
这段代码的哪一部分告诉 Safari 打开,我怎样才能阻止这种情况发生?如果只打开 Chrome 并且我在 Chrome 中运行它,我不想也不需要 Safari 打开。
提前谢谢...
on run {input, parameters}
tell application "System Events" to set frontApp to name of first process whose frontmost is true
if (frontApp = "Safari") then
using terms from application "Safari"
tell application frontApp to set currentTabUrl to URL of front document
tell application frontApp to set currentTabTitle to name of front document
end using terms from
else if (frontApp = "Google Chrome") then
using terms from application "Google Chrome"
tell application frontApp to set currentTabUrl to URL of active tab of front window
tell application frontApp to set currentTabTitle to title of active tab of front window
end using terms from
else
return "You need a supported browser as your frontmost app"
end if
set myInfo to ("MUSIC - " & currentTabUrl & " - " & currentTabTitle)
return myInfo
结束运行
【问题讨论】:
标签: google-chrome safari applescript automator