• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
"tell" to a running process
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"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.

  • Follow-Ups:
    • Re: "tell" to a running process
      • From: Steven Angier <email@hidden>
  • Prev by Date: Re: Getting the Documents Folder
  • Next by Date: Un wanted files on the desktop, Deleting launch preferences
  • Previous by thread: Re: Mac files on Windows and web
  • Next by thread: Re: "tell" to a running process
  • Index(es):
    • Date
    • Thread