Getting a List of Running Applications
Mac OS Mac OS X Windows

This assumes you have a good understanding of what a process is and how to identify a process you'd like to manipulate . If you don’t, take a look at tip proc005 - Understanding Processes before continuing.

The Macintosh portion of this code is implemented in AppleScript, and the Windows portion is implemented using the PrcView* command line utility, and assumes that you have put the pv.exe application in the same directory as your standalone (i.e. the default "directory").

function ProcessList
  switch (the platform)
  case "MacOS"
    put "tell application" && q("Finder") && cr & \
        "set procList to the processes" & cr & \
        "set procNames to" && q("") & cr & \
        "repeat with p in procList" & cr & \
        "set procNames to procNames & the name of p & ascii character 10" & cr & \
        "end repeat" & cr & \
        "return procNames" & cr & \
        "end tell" into tScript
    do tScript as AppleScript
    put the result into tProcesses
    delete char 1 of tProcesses  -- removes preceding quote
    delete last char of tProcesses  -- removes trailing quote
  case "Win32"
    set the hideConsoleWindows to true
    put shell("pv -q") into tProcList
    put "" into tProcesses
    set the itemDel to tab
    repeat for each line tProc in tProcList
      put item 1 of tProc into tProc
      append tProc,tProcesses
    end repeat
  end switch
  return tProcesses
end ProcessList

function q what
  return quote & what & quote
end q

on append what,@toWhat
  put what into line (the number of lines of toWhat)+1 of toWhat
end append
Note that the use of ascii character 10 is needed because the AppleScript separates the names with a "return" which to AppleScript is ascii 13. MC/Rev uses ascii 10 for an end of line instead. Also note that the first and last characters of the returned value will be quotes, so you'll need to remove them in your script once you have the data. Also note that there is a second or so delay in getting the list of processes from AppleScript, so you should put up a watch just before the call.

* PrcView is a command line utility developed by Igor Nys, and can be downloaded at PrcView is free for personal use or to be distributed with freeware applications; for shareware or commercial use, please contact Igor. Licensing costs are very reasonable, and he is very willing to work with you to make it worth your while to use his application.

Mac Version: Originally posted 7/21/2002 by Sarah Reichelt to the Use-Revolution List   (See the complete post/thread)

Combined version posted 12/26/2002 by Ken Ray