Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dryJ

macrumors newbie
Original poster
Oct 12, 2008
21
0
Me again :cool:

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.
 

isharan

macrumors member
Jun 3, 2009
52
0
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);
 

dryJ

macrumors newbie
Original poster
Oct 12, 2008
21
0
Sorry, I forgot to add Applescript to the title :rolleyes: Is there a way of doing this in Applescript? Thanks for your efforts though :)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
or the single-line version:
Code:
tell application "System Events" to get the name of every process whose background only is false
 

mysterytramp

macrumors 65816
Jul 17, 2008
1,334
4
Maryland
Finder can do something similar.

Code:
tell application "Finder"
	get the name of every process whose visible is true
end tell

mt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.