我正在尝试将 URL 发送到 chrome 以查看 flash,同时退出 Safari,以免耗尽内存,然后在我退出 Chrome 后立即返回 Safari。在我退出 Chrome 后,无法预料会返回 Safari,因此我需要有关重复循环的帮助。我想将其作为服务运行。谢谢!
property theURL : ""
on run {input, parameters}
tell application "Google Chrome"
activate
end tell
tell application "Safari"
activate
end tell
tell application "System Events"
keystroke "j" using {command down} -- Highlight the URL field.
keystroke "c" using {command down}
keystroke "w" using {command down}
end tell
delay 0.1
tell application "Safari"
quit
end tell
tell application "Google Chrome"
if (count of (every window where visible is true)) is greater than 0 then
tell front window
make new tab
end tell
else
make new window
end if
set URL of active tab of front window to the clipboard
activate
end tell
repeat
if application "Google Chrome" is not running then exit repeat
delay 5
end repeat
tell application "Safari"
activate
end tell
return input
end run
更新!这是工作脚本:
property theURL : ""
on run
tell application "Safari"
activate
set theURL to URL of document 1
quit
end tell
tell application "Google Chrome"
activate
if (count of (every window where visible is true)) is greater than 0 then
tell front window
make new tab
end tell
else
make new window
end if
set URL of active tab of window 1 to theURL
activate tab 1
end tell
repeat
tell application "System Events"
if "Google Chrome" is not in (name of application processes) then exit repeat
end tell
delay 5
end repeat
tell application "Safari"
activate
end tell
end run