Is there a way to limit how frequently you can start an application?

Solution 1:

You can do this using AppleScript :

1. Open AppleScript Editor

2. Paste following code:

property appName : "Mail"
property minSecsBetweenLaunches : 600 -- seconds
property checkEvery : 5 -- seconds

-- DO NOT MODIFY AFTER THIS LINE IF NOT SURE --

property lastSeenOpen : ""
property lastMailState : ""

on run
    idle
end run

on idle
    my check()
    return checkEvery -- check every n seconds
end idle

on check()
    tell application "Finder" to set processes_names to name of processes
    if (lastMailState is "") then
        -- First run
        set lastMailState to (processes_names contains appName)
        if lastMailState then
            set lastSeenOpen to current date
        end if
    else
        if (processes_names contains appName) then
            if (lastMailState is false) then
                -- App just started
                set lastMailState to true
                if (lastSeenOpen is not "") then
                    -- Already been launched, check if launch allowed
                    set timeLeft to minSecsBetweenLaunches - ((current date) - lastSeenOpen)
                    if (timeLeft > 0) then
                        tell application appName to quit
                        activate
                        display dialog "Wait " & timeLeft & " sec. before opening " & appName & " again."
                    end if
                end if
            end if
            set lastSeenOpen to current date
        else
            if (lastMailState is true) then
                -- App just quit
                set lastMailState to false
            end if
        end if
    end if
end check

3. Adjust settings

The 3 first lines of the script can be edited to fit your needs. By default, check every 5 seconds if Mail has not been seen open since 10 min (which is 600 seconds).

4. Create the app

File menu > Export

  • Choose app name & destination
  • select to export as Application
  • check "stay open..."

5. Hide from dock

In the Finder, find the app you just exported, then right-click on it, and select "Show package content". Then open "Info.plist" of the "Contents" folder in TextEdit, and, before the last </dict> of the file, paste:

<key>LSBackgroundOnly</key>
<string>1</string>

For info, after edit, end of my file looks like :

[...]
        <string>event log</string>
    </dict>
    <key>LSBackgroundOnly</key>
    <string>1</string>
</dict>
</plist>

And save it of course.

6. Set your app as startup item

System Preferences > Users > ...

Solution 2:

It would be pretty easy for someone to write a utility control app use in OS X, and it looks like someone already has. Have a look at Mac App Blocker. It has per-app granularity and restriction-by-schedule. It doesn't currently have the ability to limit an app to X launches per-hour / per-day.

I emailed this feature request to the developer:

Feb. 20, 2013
Can you add the ability to limit an application to launching  x number of 
times per hour, per day, or per week?  And, related, to limit an app to 
launching *no more than* once every x hours, days, or weeks?

Got this reply:

Feb. 21, 2013
I have had a few other requests along the same lines. Perhaps it would be 
a good idea to add this kind of functionality. As Mac App Blocker has 
progressed over the past year, it has become more feature rich and, 
possibly a little more complicated. As it is, we're trying to fulfill 
more requests while keeping the app simple to use. I like your idea and I 
would like to add something to MAB for these types of options.
I will definitely add this to our growing list of feature requests.
Hopefully, we'll get this added in a (near) future release.

Ken
<censored>@<censored>.com
KnewSense, LLC

Check up on that app in 6 months or a year, maybe it'll get added.


Last-ditch options might include pouring epoxy into the keyboard, handcuffing the problem user, or removing mains power from the building.

Solution 3:

Yes, it's call Willpower 1.0. :-)

Seriously, the only thing I can think of is Parental Controls, which can limit certain actions by time of day, but I don't think that's what you want. There are probably other apps designed to limit kids' activity on Macs that might have finer-grained controls.