Utility that locks full screen app

Discussion in 'Mac Apps and Mac App Store' started by james948, May 5, 2015.

  1. james948 macrumors 6502

    Joined:
    Nov 17, 2004
    #1
    Hi there,
    I'm looking for a focus/concentration app that locks me to one screen for a period of time.

    Too often do I switch from my writing app of choice to "check" something on the web only to discover, half an hour later, I'm fifteen levels into wikipedia with no idea what I came on to search for.

    I'd like to prevent app switching (without a password) so I can remind myself not to switch and to deter me from doing it.

    Sort of like Guided Access on iPhone.

    Thus far, I can't find anything apart from people advising to make a new managed account.

    Any ideas?
    Thanks
    James
     
  2. 0d085d macrumors regular

    Joined:
    Apr 23, 2015
    #2
    Applescript can do this:

    Code:
    set releasePassword to "bing"
    
    on waitForFocusLost(appName)
    	tell application appName
    		repeat
    			if not frontmost then
    				return
    			end if
    		end repeat
    	end tell
    end waitForFocusLost
    
    set lockedApp to text returned of (display dialog "Which application do you want to lock?" default answer "Safari")
    tell application lockedApp
    	activate
    	set frontmost to true
    end tell
    delay 1
    repeat
    	waitForFocusLost(lockedApp)
    	tell application lockedApp
    		display dialog "Enter the password to leave this application" default answer "" buttons {"Never mind", "Release!"} default button "Never mind"
    		if button returned of result is not "Never mind" then
    			set userPass to text returned of result
    			if userPass is equal to releasePassword then
    				return
    			end if
    			display dialog "Wrong password!"
    		end if
    		activate
    	end tell
    end repeat
    
    Use Script Editor to File->Export... the script as an application after you've set your password on the first line. You can then run the application to lock yourself into a particular app.

    Note:
    1. Application names are case insensitive. If you get it wrong it'll ask you to choose from a list.
    2. The "Never mind" button is deliberately the default so that you have to deliberately use the mouse to release yourself.
     
  3. james948 thread starter macrumors 6502

    Joined:
    Nov 17, 2004
    #3
    WOW! Did you just write this? This is superb!

    ----------

    Any ideas what this means?

    Scrivener got an error: Can’t set frontmost to true. (-10006)
     
  4. 0d085d macrumors regular

    Joined:
    Apr 23, 2015
    #4
    Haha, thanks!

    Whoops, looks like frontmost doesn't work in non-Apple apps. Never mind - try this instead:

    Code:
    set releasePassword to "bing"
    
    on waitForFocusState(appName, triggerState)
    	tell application appName
    		repeat
    			if frontmost is equal to triggerState then
    				return
    			end if
    		end repeat
    	end tell
    end waitForFocusState
    
    set lockedApp to text returned of (display dialog "Which application do you want to lock?" default answer "Scrivener")
    tell application lockedApp to activate
    waitForFocusState(lockedApp, true)
    repeat
    	waitForFocusState(lockedApp, false)
    	tell application lockedApp
    		activate
    		display dialog "Enter the password to leave this application" default answer "" buttons {"Never mind", "Release!"} default button "Never mind"
    		if button returned of result is not "Never mind" then
    			set userPass to text returned of result
    			if userPass is equal to releasePassword then
    				return
    			end if
    			display dialog "Wrong password!"
    		end if
    		activate
    	end tell
    end repeat
    
     
  5. james948 thread starter macrumors 6502

    Joined:
    Nov 17, 2004
    #5
    This is great! Thanks so much.

    To be honest, if it had a few settings and didn't let me change spaces at all, I'd have no problem paying £1.99 for it! You should slap it in the app store!
     
  6. 0d085d macrumors regular

    Joined:
    Apr 23, 2015
    #6
    Way too much box-ticking required. Compliment appreciated nonetheless! Happy to have helped.

    Ah, assumed it already did this. If you're not using any external displays, a quick "delay" fixes that:

    Code:
    set releasePassword to "bing"
    
    on waitForFocusState(appName, triggerState)
    	tell application appName
    		repeat
    			if frontmost is equal to triggerState then
    				return
    			end if
    		end repeat
    	end tell
    end waitForFocusState
    
    set lockedApp to text returned of (display dialog "Which application do you want to lock?" default answer "Scrivener")
    tell application lockedApp to activate
    waitForFocusState(lockedApp, true)
    repeat
    	waitForFocusState(lockedApp, false)
    	tell application lockedApp
    		activate
    		delay 0.3
    		display dialog "Enter the password to leave this application" default answer "" buttons {"Never mind", "Release!"} default button "Never mind"
    		if button returned of result is not "Never mind" then
    			set userPass to text returned of result
    			if userPass is equal to releasePassword then
    				return
    			end if
    			display dialog "Wrong password!"
    		end if
    		activate
    	end tell
    end repeat
    
     
  7. trainwrecka macrumors 6502

    Joined:
    Apr 24, 2007
    Location:
    Texas
    #7
    There was a great app called "Concentrate" that allowed you to enter a zone that only allowed for access to certain apps and certain websites depending on the task you wanted to accomplish. The newer versions of OSX killed its functionality.

    As an alternative - and since most time waste comes from the web - I use WasteNoTime extension in Safari. Works great.
     
  8. frbrn macrumors newbie

    frbrn

    Joined:
    Nov 9, 2015
    #8
    This is the perfect focus app, just genius. I was initially confused at how the app seemed to know I wanted to focus on Scrivener, esp as it's such a niche app, and then I noticed the default in the script — good luck with your writing project(s)!
     

Share This Page