Open URL in new Safari tab with AppleScript

前端 未结 12 1744
挽巷
挽巷 2020-12-13 12:43

Is it possible to use AppleScript to open a link in a new tab in Safari?

12条回答
  •  难免孤独
    2020-12-13 13:10

    Not the shortest solution but also works, and not only in English ...

    tell application "Safari"
        activate
    end tell
    
    tell application "System Events"
        set frontmost of process "Safari" to true
        keystroke "t" using {command down}
    end tell
    
    set myURL to "anyurl.html"
    delay 2
    tell application "Safari" to set the URL of the front document to myURL
    

提交回复
热议问题