我正在爲我學校的皮卡系統編寫腳本。當我收到Gmail時,是否有辦法讓我的applescript觸發?我已經嘗試將它與IMAP連接到mail.app並制定觸發它的規則,但即使我收到電子郵件,我的郵件規則也不會觸發。有什麼建議麼?附:請不要在你的回答中使用任何編碼或蘋果字符巨型行話,我在這方面是一個業餘愛好者。Applescript to trigger on incoming Gmail
##define procedure to edit googledoc
on writeToTheGoogleDoc(listContent)
##Edit the Google Document
set studentClass to (item 3 of listContent)
tell application "Google Chrome" to activate
tell application "System Events"
tell process "Google Chrome"
##open a new window
keystroke "n" using command down
##open the correct google doc according to which class student is in
if studentClass = "6A" then
keystroke "https://docs.google.com/document/d/1qYeDyVwggR0nzH7YURsjS1pGx03kSwfkDz2DFiNYETY/edit"
else if studentClass = "6B" then
keystroke "https://docs.google.com/document/d/1lyTg9CZdQUcpoc8QOl592nNdQiFH_GTLvRtGeDeUSII/edit"
else if studentClass = "7A" then
keystroke "https://docs.google.com/document/d/1_njYvXfDZHpx7OFAHTnfpfyO0R2476gxFxjl9m2QMLc/edit"
else if studentClass = "7B" then
keystroke "https://docs.google.com/document/d/1g951YT5M4VOee-kuOK4TqstiQqozU5FyhcaHUUJJmHM/edit"
else if studentClass = "8A" then
keystroke "https://docs.google.com/document/d/1fhCmMRSPCfmXOimyd2pnR273k8Ykzio4x_3S28dPAMQ/edit"
else if studentClass = "8B" then
keystroke "https://docs.google.com/document/d/1gWmEKdjJIBnLzaC1_m3obIzhM2mlUeOxEXVRkGzcPiM/edit"
end if
##press return so the webpage will load, wait for it to load
keystroke return
delay 3
##write the text to the opened google doc
set messageToBePosted to (item 1 of listContent) & ": PICKUP BY " & (item 2 of listContent)
keystroke messageToBePosted
##press return so next message will be on a new line
keystroke return
##wait so the google doc has time to commit changes
delay 2
##close the window
keystroke "w" using command down
end tell
end tell
end writeToTheGoogleDoc
##run the procedure
set contentList to {}
tell application "Mail"
set carpoolMessages to (get every message of mailbox "CARPOOL" whose subject contains "CARPOOL")
repeat with eachMessage in carpoolMessages
set end of contentList to (content of eachMessage)
end repeat
end tell
repeat with eachContent in contentList
set AppleScript's text item delimiters to ":"
set theContentList to every text item of eachContent
set item 3 of theContentList to (text 1 thru 2 of item 3 of theContentList)
writeToTheGoogleDoc(theContentList)
delay 0.5
end repeat
這是關於郵件規則,而不是Applescript,並且很可能屬於[超級用戶](http://superuser.com/) –
您有AppleScript郵件規則以及達裏克,這個問題是相當不錯的 –
@djbazziewazzie如果很清楚這是OP所要求的規則,這可能是一個很好的問題。但是沒有上下文和一個特定的要求來避免「編碼或applescript巨無霸」。 –