Вчера я пытался внедрить яблочный скрипт в Airmail (v4.0.4), который должен загрузить вложение, а затем создать запись в SideNotes (также может быть приложением Apple Notes). Но после многих разочаровывающих часов исследований я сдался. Кажется, что в Airmail невозможно запустить appleScript с целью управления другими приложениями. Следовательно, я не понимаю почему, мой вопрос: почему ?! Почему нельзя сказать Airmail в блоке «скажи - скажи» что-то сделать. В Хейзел, кстати, это возможно. Просто в Airmail я получаю эти проблемы.
Мой AppleScript выглядит следующим образом:
property DOWNLOADS : "~/Downloads"
on processMessage(theMessage)
try
tell application "Airmail"
activate
say "Process Invoice download started" using "Allison"
set dateObj to (current date)
set theMonth to text -1 thru -2 of ("0" & ((month of dateObj) - 1 as number))
set theDay to text -1 thru -2 of ("0" & day of dateObj)
set theYear to year of dateObj
set dateStamp to "" & theYear & "-" & theMonth
dateStamp
set numberOfAttachments to the count of mail attachments of theMessage
if numberOfAttachments is 0 then
display alert "Airmail" message "There are no attachments in this message" as warning
return
else
set i to 1
repeat until i = numberOfAttachments + 1
set theAttachment to filename of mail attachment index i of theMessage
set theAttachmentFile to quoted form of POSIX path of theAttachment
do shell script "cp " & theAttachmentFile & " " & DOWNLOADS & "/Rechnung_" & dateStamp & ".pdf"
set i to i + 1
end repeat
end if
end tell
end try
say "Process Invoice download completed" using "Allison"
display notification "attachment successfully downloaded." with title "Mail Download successfull" sound name "Hero"
end processMessage
tell application "SideNotes"
activate
set theFolder to folder "Notifications"
set oldText to text of last note in theFolder
set theText to "asdf"
set text of last note in theFolder to oldText & return & theText
end tell
Я хотел бы использовать приложение SideNotes, но также попробовал выше с Apple Notes. Но безуспешно.
Лучший Марко