Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automatically disable screensaver password lock

Hi folks,


I've been tinkering with the 'BlockParty' script for iTunes (this one from Doug's Applescripts collection). I want to run it once per day, before I automatically start the playlist at a certain time.

I've created an automator action to launch the 'Block Party.app, 'Pause' 5 seconds, 'Watch me Do' to click the 'proceed' button, 'Pause' 10 seconds, then 'Quit' the app. This works when I'm in front of the Mac, but when my screensaver is running (with password lock, because I have kids) the script executes but doesn't actually clock the 'proceed' button. I assume this is because the screensaver is on.

(NB I realise 'Watch me do' isn't the ideal way to click a button, but I tried many variations of using applescript to click the 'proceed' button and/or hit 'return' ... but all failed.)

I asked Doug and he suggested using launchd. I have a little experience with launchd but as far as I knew all it can do is re-start a process if it quits. I can't see how it will help here.

I've done some googling on ways to disable the screensaver but have come up blank. I've found pages like this one which discuss how to enable/disable it, but it looks like it would only work if the Mac isn't already displaying a screensaver.


Any ideas? Thanks!

iMac (Retina 5K, 27-inch, Late 2015), OS X El Capitan (10.11.4), null

Posted on Apr 24, 2016 3:51 AM

Reply
7 replies

Apr 24, 2016 5:28 AM in response to Timothy Houghton

Never mind! Typing this all out got me interested in this problem again, and I've finally figured it out. The automator action goes like this:


1. Launch Application - Block Party.app

2. Pause - 5 seconds

3. Run Applescript

tell application "System Events" to set require password to wake of security preferences to false

4. Run Applescript

tell application "ScreenSaverEngine"

quit

end tell

5.Run Applescript

tell application "Block Party"

activate

end tell

6. Watch Me Do - Click the 'Proceed...' button, playback speed x10

7. Pause - 10 seconds

8. Quit Application - Block Party.app

9. Run AppleScript -

tell application "Finder"

set the visible of process "iTunes" to false

end tell

10. Run Applescript -

tell application "System Events" to set require password to wake of security preferences to true

11. Start Screen Saver


Step 4 is important, otherwise you end up with a visible desktop but your keyboard won't work at all, and the mouse only works for apps other than Finder. You can't even reboot without holding the power button. At first I tried to use Automator's 'Quit App' feature for this step, but I couldn't select ScreenSaverEngine.app (the app is greyed out).


I've left all the individual applescript snippets as separate steps for now, will probably try and consolidate them at some point.


I run this at 6am every morning, so I'm not too worried about long pauses here and there.

Apr 24, 2016 5:41 AM in response to Timothy Houghton

There might be some useful information in this MacScripter posting.


A launchctl script can be written to run an application or script on a frequency that you code into it (e.g. daily at 10 am).


A Doug's Applescript article on creating a launchd script that runs on startup and then every 8 hours afterward.


How to run an Automator workflow at 7am daily.


A Launchd Tutorial. (Launchd configuration on El Capitan may be slightly different)... see man launchd, man launchd.plist, and man launchctl.

Apr 24, 2016 6:05 AM in response to VikingOSX

Thanks for your input!


The issue was really how to click the 'Proceed' button while the screensaver was active. The bit I was missing was how to use Applescript to disable the screensaver password, and belatedly realising that ScreenSaverEngine is just an app which I could launch and quit as needed.


I'm using cron to launch the automator script every day. I don't use the command line much, so I prefer to use CronniX for a basic GUI.

May 3, 2016 8:27 AM in response to Timothy Houghton

I have step 4 exactly as you do, but I am still having the issue you described with the visible desktop and disabled keyboard. Very strange.


Below is a different approach, but same idea, which I think I got working correctly. It basically types in your password into the screensaver, which you can store in keychain rather than clear txt. Also uses the system caffeinate command which wakes a sleeping mac.


https://github.com/atika/bluesense/blob/master/Device%20Detected%20AppleScripts/ disable-screen-saver-password.applescript


Likewise this works the same way, but slightly different method:

https://gist.github.com/hiilppp/10922837


I liked your solution better, but basically force quitting ScreenSaverEngine doesn't work on my mac.


Thanks!

May 3, 2016 11:34 AM in response to aypy

How strange! It seemed to me that the visible desktop / disabled keyboard symptom suggested that the screensaver was still running, but we had woken the 'display' portion of it. But if it doesn't work for you I may have that wrong.


One thing I forgot to mention in the little write up above is that I also had to add my automator action as an allowed app in the 'Privacy' pane in System Prefs. In fact while testing I also had to add Script Editor, Automator and Terminal to it as well.


That caffeinated command is very interesting, thanks for sharing that. I like the idea of using the keychain. I was a bit surprised I could disable the screensaver password from automator so easily.

Automatically disable screensaver password lock

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.