keeping application alive

Discussion in 'Mac Programming' started by mehdies, May 7, 2013.

  1. macrumors member

    Joined:
    Jun 10, 2012
    #1
    i have an application that used a while loop(for test) for keeping alive.this app must be running ever.how i can use LaunchDaemons(must be running as root) instead of while loop?

    KeepAlive option exactly do that? like while?!

    Thanks
     
  2. macrumors regular

    Joined:
    Mar 2, 2013
    #2
    you are not trying to write a malware, are you?
     
  3. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #3
    Malware?! why? My application alert when active(focused) app is Finder! just this.so i want to keep application alive.
     
  4. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #4
    Is there any way to run application when active(focused) app is Finder(or any exciting app)?
    I mean application is not needed active ever and when focused app is Finder my application run .... or if focused app was changed my application run once(this is better)
     
  5. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Go into your target's info and set "Application is agent (UIElement)" to YES. That'll change your app to run in the background. It won't show up in the dock or in the force quit menu... The only ways I know of to stop an application that's running that way is to go into Activity Monitor or Terminal and use kill on it.
     
  6. mehdies, May 8, 2013
    Last edited: May 9, 2013

    thread starter macrumors member

    Joined:
    Jun 10, 2012
    #6
    I can't find "Application is agent (UIElement)"? must be add manually?

    edit : I add manually and application run in background but not do correct.
    I remove while loop in application source code and set "Application is agent .." to YES but application run once
     
  7. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #7
    Can i use Quartz event services?
     
  8. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #8
    It won't change the logic of your code - you must find a way to make it run more than once. I often use repeating NSTimers for code that should run every few minutes without user input.
     
  9. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #9
    Thanks for your reply.
    I want to run my code when focused window(active application) is changed.i don't know what i must be use!

    Is there any system event like Change Focused window or app?
     
  10. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #10
    I wouldn't think so... What are you trying to do, exactly? It seems to me that often when someone is asking a question like this, they're taking a very difficult approach to an easy problem.
     
  11. thread starter macrumors member

    Joined:
    Jun 10, 2012
    #11
    I exactly want to create an application or piece of code that whenever focused app or window changed my app get title of focused application and if title will be "Finder" do something.just this
     

Share This Page