0
我正在嘗試使用聽寫功能使用語音命令自動化我的Mac。我有以下簡單的腳本,即使Safari瀏覽器被關閉,這將開闢一個新的Safari瀏覽器標籤頁中的URL:使用AppleScript自動化Safari:基於URL智能切換到已經打開的選項卡
tell application "Safari"
activate
end tell
set theUrl to "https://mail.google.com/mail/u/0/#inbox"
tell application "Safari"
if not (exists current tab of front window) then make new document -- if no window
tell front window
set current tab to (make new tab at end of tabs with properties {URL:theUrl})
end tell
end tell
它的偉大工程。我可以說「Mac,打開Gmail」,它會彈出。不過,我想看看是否可以改進腳本,並讓腳本確定站點是否已在另一個選項卡中打開,如果是,則切換到該現有選項卡。有沒有辦法獲得包含我想要的網址的第一個標籤的編號?