0
我使用下面的代碼在谷歌查詢在applescript中打開youtube,因爲新的谷歌不會將我的搜索字符串帶到youtube.Unable在Firefox中打開url與谷歌搜索字符串Firefox瀏覽器。我非常感謝任何幫助。提前感謝。applescript在YouTube上打開谷歌搜索查詢
在這裏,我得到一個錯誤:
tell application "Firefox" to activate
tell application "System Events"
keystroke "l" using command down
keystroke "c" using command down
set tr to get the clipboard
end tell
return trimgoogle(tr)
on trimgoogle(sourceAddress)
set AppleScript's text item delimiters to {"#"}
set addressParts to (every text item in sourceAddress) as list
set AppleScript's text item delimiters to ""
set nameOnly to item 2 of addressParts
set AppleScript's text item delimiters to {"&"}
set addressParts2 to (every text item in nameOnly) as list
set AppleScript's text item delimiters to ""
set nameOnly1 to item 1 of addressParts2
set nameOnly2 to nameOnly1
set AppleScript's text item delimiters to {"="}
set addressParts21 to (every text item in nameOnly2) as list
set AppleScript's text item delimiters to ""
set nameOnly12 to item 2 of addressParts21
set newurl to "http://www.youtube.com/results?search_query=" & nameOnly12
return newurl
end trimgoogle
tell application "Firefox"
OpenURL newurl
end tell
我想,也不過它什麼也不做!代碼中沒有錯誤,但是新窗口(選項卡未打開)。 – jason
嘗試使用硬編碼的網址。如果它工作,你必須編碼你的網址(在這種情況下,「nameOnly12」的內容) - 我只是在OS 10.8.2上再次嘗試使用最新的Firefox,它打開一個有效的位置 – 2013-10-14 08:48:13
使newurl全球化,它開始工作。你可以告訴我任何其他方式來做到這一點,而不是使紐羅爾全球? – jason