Как я могу вернуть результат (из Applescript) в следующий рабочий процесс? - PullRequest
0 голосов
/ 13 февраля 2012

извините за то, что я новичок в Applescript & Automator.

Мне был создан рабочий процесс (с использованием 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

1 Ответ

1 голос
/ 14 февраля 2012

Это небрежно, но все же работает.

В настройках заставки сохраните свои скриншоты в: / Users / Mark / Documents / Twin

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
...