RE:First Applescript
RE:First Applescript
- Subject: RE:First Applescript
- From: "email@hidden" <email@hidden>
- Date: Tue, 18 May 2004 18:37:55 -0400
- Priority: normal
Hi Joshua,
I'm not sure what process you're wanting to watch, but if
it's an application you can run something like this to see
what applications are currently open:
-----
tell application "Finder"
set openApps to name of processes
end tell
openApps
-----
which on my machine returns:
{"loginwindow", "Dock", "SystemUIServer", "Finder",
"Safari", "Mail", "Script Editor", "System Events"}
One solution you might try is making a 'Stay Open' script
with the following code (this example checks to make sure
'TextEdit' is open every 5 minutes, and if not then it opens
it):
-----
on idle
tell application "Finder"
set openApps to name of processes
end tell
if "TextEdit" is not in openApps then
tell application "TextEdit" to activate
end if
-- Script pauses until time passes below
return 300 -- 300 seconds
end idle
-----
Once you paste this code in Script Editor, make sure to
select 'Application' from the popup button and also select
'Stay Open' (in the 'Save As' dialog). Once you double
click on the script icon it will continue to run until you
manually select it and quit it.
Also, if you're not wanting the script to bring the
application to the front if it opens it, then use 'launch'
instead of 'activate' like so:
-----
on idle
tell application "Finder"
set openApps to name of processes
end tell
if "TextEdit" is not in openApps then
tell application "TextEdit" to launch
end if
-- Script pauses until time passes below
return 300 -- 300 seconds
end idle
-----
Hope that helps.
Jay
==========
Subject:
First Applescript
To:
<email@hidden>
From:
"Web Manager" <email@hidden>
Date:
Tue, 18 May 2004 15:48:43 -0500
Hi List,
I must confess up front that I am a recent PC convert and
that this is my
*first* task in Applescript. I don't really have an
execution question yet
as much as an approach question. Here is what I want to
accomplish.
I want to see if a particular process is running,
if the process is running I want the script to sleep for 5
minutes and try
again
if the process has stopped I want it to re-launch the
associated application
sleep for 5 minutes and try again.
I can do this with AutoIT on the PC side no problem but
since this is my
first Applescript I'm not sure what to do first, here is my
question.
Do I actually have to open something like Terminal > run top
>
look for
'such&such process' and then manipulate it or can I just
create an if
statement to accomplish the whole thing...
Something like this (pardon my ignorance):
if such&such process is running wait 5 minutes
else start such&such application and wait 5 minutes
& loop
Thanks in advance,
Joshua
_______________________________________________
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.