Safari中标签之间的Applescript切换

Safari中标签之间的Applescript切换,safari,applescript,Safari,Applescript,尝试创建自动化,以打开带有多个选项卡的Safari浏览器,并登录到我每天使用的常用网站。我已经打开了浏览器,添加了带有特定URL的新标签,并提示用户输入用户名和密码,但我很难在打开的标签之间移动。 我尝试过分配索引、命名“当前选项卡”、使用标题等。似乎没有任何效果。。。见下面的示例 --Prompt user for login information set GEmail to text returned of (display dialog "Enter Password" with tit

尝试创建自动化,以打开带有多个选项卡的Safari浏览器,并登录到我每天使用的常用网站。我已经打开了浏览器,添加了带有特定URL的新标签,并提示用户输入用户名和密码,但我很难在打开的标签之间移动。 我尝试过分配索引、命名“当前选项卡”、使用标题等。似乎没有任何效果。。。见下面的示例

--Prompt user for login information
set GEmail to text returned of (display dialog "Enter Password" with title "Gmail" default answer "")
set GPassword to text returned of (display dialog "Enter Password" with title "Gmail" default answer "")
--Activate Safari and open new tab with URL
tell application "Safari"
    activate
    make new document with properties {URL:"https://gmail.com"}
    delay 3
    tell application "System Events"
        delay 2
        keystroke tab
        keystroke GEmail
        delay 2
        keystroke tab
        keystroke GPassword
        keystroke return
        end tell
--Create new tab pointing to Google > this does not actually open the new tab
set the URL of (make new tab in window 1) to "http://www.google.com"
end tell

我尝试了多种方法,但似乎仍然无法在选项卡之间移动,最终需要添加多个选项卡,我需要在这些选项卡之间切换。

要创建新的选项卡,同时在给定的URL处设置焦点,请使用,例如:

tell application "Safari" to ¬
    tell front window to ¬
        set current tab to ¬
            (make new tab with properties {URL:"http://www.google.com"})

能否更具体地说明如何在选项卡之间移动?如果您想用键盘在它们之间循环,那么命令shift-}可以使右边的选项卡成为当前选项卡。如果要在将选项卡设置为当前选项卡的同时创建新选项卡,则打开位置“”是一种方法。我不完全理解你想要达到的目标。还有,Safari没有密码管理吗?不确定您使用的是什么版本。它可能比使用applescript更安全(但这只是我的猜测)。