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 Jan 27, 2013, 07:43 AM   #1
Amad3U5
macrumors member
 
Join Date: Nov 2012
Location: Sydney
[AppleScript] Check what application is running in the foreground

I want to write an AppleScript that will force-quit the application running in the fore-ground (i.e the application in the status bar).

How can I use AppleScript to determine what that application is?
__________________
 27" Sandy Bridge iMac; 13" 2012 MacBook Air; iPhone 5 
______________________________________________________________
In a world of without walls and fences, who needs Windows and Gates?
Amad3U5 is offline   0 Reply With Quote
Old Jan 27, 2013, 09:06 AM   #2
bumper314
macrumors member
 
Join Date: Jun 2009
Code:
tell application "System Events"
	processes whose frontmost is true
end
bumper314 is offline   1 Reply With Quote
Old Jan 27, 2013, 01:16 PM   #3
Mark FX
macrumors member
 
Join Date: Nov 2011
Just expanding on what bumper314 has posted.

Code:
tell application "System Events"
	set frontmostApp to name of application processes whose frontmost is true
	tell application frontmostApp
		quit
	end tell
end tell
This wont work in Applescript Editor, as Applescript editor will be the fronmost app, and will still be processing and running the script, so will only work when the script is compiled.

Regards Mark
Mark FX is offline   1 Reply With Quote

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

Tags
applescript

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


All times are GMT -5. The time now is 02:24 AM.

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

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