Applescript, wait for process launch.

Discussion in 'macOS' started by Lokrado, Aug 4, 2010.

  1. Lokrado macrumors regular

    Joined:
    Jan 26, 2009
    Location:
    Denmark
    #1
    I need an AppleScript that will continousley check if a specific process is running, then initiate something once this process is running. I tried about a hundred different things but nothing will work
     
  2. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #2
    Try this:

    Code:
    processCheck()
    on processCheck()
    	tell application "System Events" to get name of every process
    	if the result contains "Finder" then
    		beep --put your actions here
    		
    	else
    		processCheck()
    	end if
    end processCheck
    Just replace Finder with the process you want and beep with the action you want it to run. Be careful, this script can run away sometimes.
     
  3. Caleb531 macrumors 6502

    Caleb531

    Joined:
    Oct 17, 2009
    #3
    That works, but this is simpler:

    Code:
    repeat until application "Safari" is running
    	delay 1
    end repeat
    -- do something once it's running
     
  4. Lokrado thread starter macrumors regular

    Joined:
    Jan 26, 2009
    Location:
    Denmark
    #4
    This doesn't work as it's not a GUI app I'm working with but rather a terminal utility, that's why I wrote process :D
     
  5. Lokrado thread starter macrumors regular

    Joined:
    Jan 26, 2009
    Location:
    Denmark
    #5
    This one doesn't work either..
    Got a bunch of funny errors encluding overflow, once I got rid of those it just seems to run for infinity without doing anything
     

Share This Page