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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Resolved: Applescript and lists Roadrun3r Mac Programming 6 Jun 5, 2011 06:20 AM
iOS 4 Calendar Apps - Listing of Cal apps that access iCal database JNGold iPhone and iPod touch Apps 8 Aug 29, 2010 09:06 AM
Let's compile a list of games/apps that clearly run better on the iPhone 3GS WilliamG iPhone 3 Jun 19, 2009 04:10 PM
8-core Mac Pro - list of Multithreaded apps? PowerMike G5 Mac Pro 35 Dec 19, 2006 04:16 PM
Applescripts - how to run on login w/out clicking run slooksterPSV Mac Applications and Mac App Store 3 Jan 20, 2005 03:10 PM


All times are GMT -5. The time now is 09:51 AM.

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

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