"tell" to a running process
"tell" to a running process
- Subject: "tell" to a running process
- From: Giuliano Gavazzi <email@hidden>
- Date: Thu, 14 Mar 2002 22:42:03 +0000
I am looking for a way to target a running copy of an application,
specified by its signature. I have to lookup the process as there are
in principle many copies of the application on disk, of which at most
one can be running at any one time.
Up until now (MacOS9) I would do the following
[ I used "\" as line continuation ]
on getProcess(theCreator)
try
set creaType to theCreator
tell application "Finder" to the first process whose \
creator type is (creaType as type class)
set theAppProc to the result as <<class psn >>
on error
return null
end try
return theAppProc
end getProcess
and this can be used as in:
set theApp to my getProcess("Foob")
using terms from application "FooBar"
tell theApp
...
end tell
end using terms from
This code does not work under MacOSX (or Classic environment). In
order to maintain the same API, getProcess must be changed to, for
MacOSX:
on getProcessX(theCreator)
try
set creaType to theCreator
tell application "Finder"
get the first process whose creator type is (creaType)
set theAppProc to (first item of result) -- A
set theAppProc to (file of theAppProc) as string -- B
end tell
on error
return null
end try
return theAppProc
end getProcess
A has been added because I get a list of one item
B has been added because I must feed a path to "tell application"
I haven't yet found a way to have this work on Classic.
Is there a better an universal method?
thanks
Giuliano
_______________________________________________
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.