2012-02-13 51 views
0

對不起,我是一個新手在Applescript & Automator。如何將(AppleScript的)結果返回到下一個工作流?

我已經創建了一個工作流程(使用Applescript)從某些網站(通過Firefox +附加「頁面保護程序」+熱鍵)獲取快照。 但我希望將圖像傳遞給另一個進程的工作流程的下一步。

接下來我該怎麼辦?

tell application "Firefox" 
    open location "http://xxx.xxx.xxx" 
    activate 

    tell application "System Events" 
     keystroke "d" using {control down} 
     -- take snapshot 
    end tell 
    delay 2 
    close every window of application "Firefox" 
    tell application "System Events" 
     keystroke return 
    end tell 
    end tell 
+0

在工作流中的另一個AppleScript的下一步? – fireshadow52 2012-02-13 21:24:37

回答

1

這是草率的,但它的工作原理。

在頁面保護程序的喜好,你的屏幕截圖保存到: /用戶/標記/文檔/雙牀

main() 

on main() 
set screenshotFolder to (alias "Mac OS X:Users:Mark:Documents:Twin:") 

tell application "Firefox" 
    activate 
    open location "http://www.stackoverflow.com" 
    delay 3 

    tell application "System Events" 
     keystroke "d" using {control down} 
     delay 2 
     set latestDate to creation date of file 1 of screenshotFolder 
     repeat with i from 2 to count of (list folder screenshotFolder) 
      if creation date of file i of screenshotFolder is greater than latestDate then 
       set latestDate to creation date of file i of screenshotFolder 
      end if 
     end repeat 

     -- The targetFile is what you are looking for 
     set targetFile to every file of screenshotFolder whose creation date is latestDate 
    end tell 
end tell 
end main 
+0

是的,我有一個類似的想法。我最初的想法是要求Finder獲取screenshotFolder中的「文件名」。你在截取屏幕截圖之前先做這件事,然後再做。然後通過第二個列表循環查看第一個列表中的名稱。當你找到一個不在第一個列表中的名字...那是你的新文件。和你一樣的想法。 – regulus6633 2012-02-14 17:25:47

相關問題