Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 27, 2013, 08: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, 10: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, 02: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

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript how to check radio button redwgaontoy Mac Programming 1 Jun 18, 2013 09:35 AM
AppleScript modification: Check if event already exist bibyfok Mac Programming 0 Dec 4, 2012 05:03 AM
Anyone know of an Applescript to check if an app is NOT running? amityweb Mac Programming 1 Oct 18, 2012 03:42 PM
AppleScript Application MacGeekJunior Mac Programming 2 Sep 2, 2012 03:12 PM
Applescript application not working within Automator Jeshua Mac Programming 0 Aug 3, 2012 07:41 PM

Forum Jump

All times are GMT -5. The time now is 01:50 PM.

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

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