Page 1 of 1

Check if App is running, don't run rule if it is

PostPosted: Wed Jun 26, 2013 3:20 pm
by openmedi
I'm using Hazel in connection with nvALT for my note taking stuff. Based on a specific renaming scheme stuff happens with my note (like archiving etc.). I would like to have my rules run, when I am not running nvALT. My idea for achieving this, was to let Hazel check, if nvALT is running (just like Keyboard Maestro is able to do), but I couldn't find something built in. I thought this is probably a problem that has been solved, but I couldn't find anything in my searches.

Does anybody know a way, maybe a script, to test for if an App is running? Any help is appreciated.

EDIT (26.06.2013 - 22:07 ) : Never mind, I figured it out myself:

I've employed an apple script to test if an app (in my case nvALT) is running or not. If that app is running the script returns false (in hazel logic this means the file didn't match) otherwise it returns true:

Code: Select all
on hazelMatchFile(theFile)
   set nvRunning to is_running("nvALT")
   if nvRunning then
      return false
   else
      return true
   end if
end hazelMatchFile
on is_running(appName)
   tell application "System Events" to (name of processes) contains appName
end is_running


It does work for me, may be it does for you, too.