2013-05-21 27 views
1

這是我的第一個Applescript。我希望能夠使用循環考慮儘可能多的項目,當列表中沒有更多附加元素時,循環將轉到下一步。我的版本現在只佔兩個文本項目。先謝謝你!如果下一項存在於列表中,那麼applescript

set userone to text returned of (display dialog "Job IDs Please" default answer "" buttons {"Submit", "Cancel"} default button 1) 

set oldDelimiters to AppleScript's text item delimiters 
set AppleScript's text item delimiters to " " 
set urllist to every text item of userone 

set joburl to "http://crowdflower.com/jobs/" 
set urlcrowds to urllist 
copy urllist to urlcrowds 
set item 1 of urlcrowds to joburl & 1st item of urllist 
set item 2 of urlcrowds to joburl & 2nd item of urllist 

get urlcrowds 

tell application "Google Chrome" 

activate 

make new window 

set myTab to make new tab at end of tabs of window 1 

set URL of myTab to item 1 of urlcrowds 

set myTab to make new tab at end of tabs of window 1 

set URL of myTab to item 2 of urlcrowds 

close tab 1 of window 1 

end tell 

非常感謝!

回答

0

您可以使用重複與循環:

set l to {12379081, 3785788, 3351991} 
tell application "Google Chrome" to tell (make new window) 
    repeat with i in l 
     set u to "http://crowdflower.com/jobs/" & i 
     make new tab at end of tabs with properties {URL:u} 
    end repeat 
    close tab 1 
end tell 

AppleScript Language Guide: Control Statements Reference

open location不會打開一個新標籤頁:

repeat with i in words of "12379081 3785788 3351991" 
    open location "http://crowdflower.com/jobs/" & i 
end repeat 

您也可以運行在終端是這樣的:

open http://crowdflower.com/jobs/{12379081,3785788,3351991} -a Google\ Chrome 
+0

真棒!終端解決方案非常棒!我很感激! – mwilstevens

相關問題