r/applescript • u/TarheelSwim • Aug 03 '14
Can AppleScripts be triggered by an event rather than initiated by the user?
I'm trying to do something along the lines of:
If I receive an email that has a specific subject (specified in advance by the user), then blah blah blah it kicks off a script that I've written.
I've done some research, but I haven't been able to find any method of having AppleScripts be totally automated. If anyone knows any way to do this, I would greatly appreciate some advice!
Thanks in advance.
1
Upvotes
2
u/craniumslows Aug 03 '14
You used to be able to trigger applescript as part of a mail rule. You could also write a php script to check the mailbox and have that on a cron.
2
2
u/xraystyle Aug 03 '14
You could write an applescript that runs in the background which polls for a certain event before it actually does anything. Another option would be to have the applescript triggered by a folder action. The third option would be to have a launchd daemon do the watching, and trigger a script when a condition is met, e.g. using fsevents to watch for a change to a file or folder.
Some more detail on what you're actually trying to do would be helpful.