Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 5, 2009, 02:58 PM   #1
dryJ
macrumors newbie
 
Join Date: Oct 2008
Applescript - list of running apps?

Me again

1. How can I go about getting a list of running apps (preferably only the apps that you can see in the Dock, I'm not bothered about background processes)so that I can get a variable to move through this list with a repeat command?

Help much appreciated.

Last edited by dryJ; Jun 5, 2009 at 03:43 PM. Reason: I forgot to mention 'Applescript' :P
dryJ is offline   0 Reply With Quote
Old Jun 5, 2009, 03:30 PM   #2
isharan
macrumors member
 
Join Date: Jun 2009
Code:
[[NSWorkspace sharedWorkspace] launchedApplications]
will return an array with all the running applications. (ones that show up in the dock)

EDIT: If you're looking for just the names of the application, use this instead: (stolen from theocacoa)

Code:
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSArray * apps;
apps = [ws valueForKeyPath:@"launchedApplications.NSApplicationName"];
NSLog (@"%@", apps);
isharan is offline   0 Reply With Quote
Old Jun 5, 2009, 03:42 PM   #3
dryJ
Thread Starter
macrumors newbie
 
Join Date: Oct 2008
Sorry, I forgot to add Applescript to the title Is there a way of doing this in Applescript? Thanks for your efforts though
dryJ is offline   0 Reply With Quote
Old Jun 5, 2009, 03:50 PM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Here's an example
Code:
tell application "System Events"
    repeat with p in every process
        if background only of p is false then
            display dialog name of p as string
        end if
    end repeat
end tell
kainjow is offline   0 Reply With Quote
Old Jun 5, 2009, 04:09 PM   #5
larkost
macrumors 6502a
 
Join Date: Oct 2007
or the single-line version:
Code:
tell application "System Events" to get the name of every process whose background only is false
larkost is offline   0 Reply With Quote
Old Jun 5, 2009, 06:35 PM   #6
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
Finder can do something similar.

Code:
tell application "Finder"
	get the name of every process whose visible is true
end tell
mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
select data to use in "Choose From List" list in applescript ShuddaRunThat Mac Programming 2 Apr 1, 2014 06:31 PM
Is there a running list of apps that you should disable App Nap on? justdep OS X Mavericks (10.9) 3 Oct 29, 2013 11:41 AM
Applescript (List Force Quit Apps) Kyp Mac Programming 9 Oct 4, 2013 10:38 PM
sorting a list of dates and times (applescript) wild4life2013 Mac Programming 2 Sep 6, 2013 08:02 PM
AppleScript - Button Returned of Results from a List JPinto Mac Programming 1 Jan 13, 2013 02:02 PM

Forum Jump

All times are GMT -5. The time now is 10:25 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC