Open URL in new Safari tab with AppleScript

前端 未结 12 1748
挽巷
挽巷 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:23

    Code:

    tell application "System Events"
    tell application "Safari" to activate
    tell process "Safari"
    click menu item "New Tab" of menu "File" of menu bar 1
    end tell
    end tell
    
    tell application "Safari"
    set URL of document 1 to "http://www.stackoverflow.com/"
    end tell
    

    One problem is that this only works if the system's language is set to English.

提交回复
热议问题