I have an AppleScript that will reload my safari browser every x amount of seconds:
activate application "Safari"
repeat
tell application "System Events" to keystroke "r" using command down
delay (5)
end repeat
As I use the "Split Screen" feature within macOS, I want to expand this code to refresh both Safari browsers.
答案 0 :(得分:0)
首先,一种重新加载当前 Safari 窗口的更好方法:
tell application "Safari" to tell the front document to set its URL to its URL
要针对多个打开的窗口执行此操作:
tell application "Safari" to repeat with D in every document
set D's URL to D's URL
end repeat
在重复循环中添加此标记,添加必要的延迟,您将拥有不断刷新的浏览器窗口:
tell application "Safari" to repeat while document 2 exists
repeat with D in every document
set D's URL to D's URL
end repeat
delay 5
end repeat