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

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 18, 2012, 08:13 AM   #1
amityweb
macrumors newbie
 
Join Date: Oct 2010
Location: Wales
Anyone know of an Applescript to check if an app is NOT running?

Hi

I have a script that moves email from Mail to Omnoficus. If both apps are running it works.

But if one or both are not running, even though the tell application script will start the app, they crash, and my script does not end, and does not work.

So I thought I would add in the activate command to start the apps if they are not running.

I can only find online functions to tell if an app is running, and not NOT running. I tried modifying it but the whole thing still crashed the same even if I did not use it (so perhaps its not being called).

This is what I have so far and wondered if anyone knows:

Code:
if appIsNotRunning("OmniFocus") then
	tell application "OmniFocus"
		activate
		delay 10
	end tell
end if


on appIsNotRunning(appName)
	tell application "System Events" to (name of processes) does not contain appName
end appIsNotRunning
The delay was just because I thought I should wait a bit for the app to finish starting just in case.

Thanks
amityweb is offline   0 Reply With Quote
Old Oct 18, 2012, 03:42 PM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Try this :

Code:
tell application "System Events"
	set isOmnifocusRunning to (count of (every process whose bundle identifier is "com.omnigroup.OmniFocus")) > 0
	set isMailRunning to (count of (every process whose bundle identifier is "com.apple.mail")) > 0
end tell
if isOmnifocusRunning and isMailRunning then
	-- if only one or none are running do nothing
	-- if both apps are running do your stuff
end if
__________________
Space Corps Directive 34124
kryten2 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
Running an AppleScript at a specific time rediffusion Mac Programming 4 Jan 7, 2014 10:09 PM
Applescript how to check radio button redwgaontoy Mac Programming 1 Jun 18, 2013 09:35 AM
[AppleScript] Check what application is running in the foreground Amad3U5 Mac Programming 2 Jan 27, 2013 02:16 PM
AppleScript modification: Check if event already exist bibyfok Mac Programming 0 Dec 4, 2012 05:03 AM
My Applescript is running like a dog under ML lloyd709 OS X 10.8 Mountain Lion 0 Jul 26, 2012 11:27 AM

Forum Jump

All times are GMT -5. The time now is 03:57 AM.

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

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