有沒有辦法做到這一點鉻?從OS X的Chrome上獲取最前面標籤的URL?
tell application "Google Chrome"
return URL of front document as string
end tell
...不起作用。
有沒有辦法做到這一點鉻?從OS X的Chrome上獲取最前面標籤的URL?
tell application "Google Chrome"
return URL of front document as string
end tell
...不起作用。
由於沒有AppleScript的支持,這是可以做到的唯一途徑是通過GUI腳本,我不知道你是多麼熟悉使用AppleScript,但GUI腳本是一個不好的做法,進入。所以請謹慎使用此代碼。它也是重要的,您可以訪問您的通用訪問首選項中的輔助設備「已啓用」。
tell application "Google Chrome"
activate
tell application "System Events"
tell application process "Google Chrome"
get value of text field 1 of tool bar 1 of window 1
end tell
end tell
end tell
現在,Chrome瀏覽器(7+)支持AppleScript的,你可以這樣做:
tell application "Google Chrome"
get URL of active tab of first window
end tell
注: 「第一窗口」 指的是最前面的窗口。
是否存在針對Chrome特定AppleScript命令的文檔?例如,如果我想要執行諸如獲取活動選項卡的HTML內容之類的東西,我在哪裏尋找方法來做到這一點? – 2010-11-28 09:05:17
除了通過在腳本編輯器中打開Chrome應用程序可以看到的字典,我找不到多少文檔。 – 2010-11-28 17:44:15
我認爲你可以使用此腳本獲得最前面的選項卡:
tell application "Google Chrome"
set frontIndex to active tab index of front window
get URL of tab frontIndex of front window
end tell
希望我得到這個權利。試試看。
或者只是告訴應用程序谷歌瀏覽器「告訴窗口1到標籤活動標籤索引的URL」。或者'告訴應用「谷歌瀏覽器」到窗口1的活動標籤的URL。 – user495470 2011-10-18 23:55:56
有一種更簡單的方法來檢索URL。
'tell application "Google Chrome" to return URL of active tab of front window'
測試和工程就像一個魅力。
啊好吧,是的,這是非常好的做法,進入 – mcgrailm 2010-03-23 16:25:50
宇!我只寫了下面的腳本,這樣我就可以更容易地使用Chrome的PasswordMaker了,謝謝你的回答! 告訴應用程序「系統事件」 \t告訴應用程序「谷歌瀏覽器」 \t \t集theURL獲得工具欄的文本字段1的值窗口的11 \t年底告訴 端告訴 集domainparts到splitText(」 (「/」,theURL)中的項目3) 將域名部件的項目((「。」,{item((count count domainparts) - 1),domainparts的項目((count count domainparts))設置爲topdom}) 請執行shell腳本「/ Users/dmd/bin/pmo」&topdom – dmd 2010-03-23 16:57:23
呃,好的,我該如何讓它的格式正確? – dmd 2010-03-23 16:57:39