Re: triggering an AppleScript
Re: triggering an AppleScript
- Subject: Re: triggering an AppleScript
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 09 May 2003 13:17:32 -0700
On 5/9/03 12:50 PM, "Carl Albrecht-Buehler" <email@hidden> wrote:
>
What methods are available to trigger an Applescript besides running it from
>
the Script eidtor, double clicking an Applet, and running one from a script
>
menu (should one be available)?
>
>
For example, are there ways of dragging and dropping files on top of an
>
applet that triggers it? If so, how does the script have to look so that it
>
knows what to do with the file?
Put all your relevant code - what you'd normally put in the main script
(top-level or run handler) into an 'open' handler. You use a variable as
parameter - which is NOT put into parentheses - and which is always a _list_
of aliases, even if you expect just one file to be dropped at a time:
on open theFiles
repeat with theFile in theFiles
-- do your stuff here, e.g.
set filePath to theFile as string --or
tell app "Finder" to set theFolder to container of theFile as alias
end repeat
end open
You save the script as an application, which becomes a droplet when it has
an 'open' handler and its icon contains the recognizable down-arrow.
>
Also, is there a way for an AppleScript to
>
run based on whether or not the comupter jsut woke up?
You can include your applet in Login Items System prefs (OS X) or Startup
Items in System Folder (OS 9) to get it to run, and hide it somewhere where
the user isn't likely to find it otherwise! If you have Jon's Commands
scripting addition, or GetMilliSec scripting addition installed, you could
put everything in an if clause after determining the ticks or milliseconds
(which is since launch). For example
set t to the tcks
if t > 3600 then return -- longer than 1 minute, quit now
(If it's in an open or other handler, make that
if t > 3600 then error number -128
). Otherwise, no, there's no way for the script to know who called it.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.