Apple Script for Screensaver as Desktop

Discussion in 'Mac Apps and Mac App Store' started by skyler440, Feb 8, 2013.

  1. skyler440 macrumors newbie

    Joined:
    Feb 8, 2013
    #1
    A while ago, I downloaded an apple script which when I clicked on it, the wallpaper was set to the ScreenSaver, and then it closed. When I clicked on it again, the wallpaper was restored and the application closed once again. I deleted it a while ago, and now I want it back, but I can't find it anywhere. All I can find are terminal codes which if I quit terminal, it stops. If anybody has any help on how to code this or find something like it, it would be great.



    Additional info- I will be using the application Spark to activate/Deactivate this with a key combo so I need it to be an application that will automatically quit.



    Thanks, Skyler
     
  2. PacSoc macrumors newbie

    Joined:
    Feb 20, 2014
    #2
    First Ever App! (Still working on it though.)

    You have no idea how happy I am that I get to post on a fairly recent comment on a forum (Usually really behind everyone as far as finally getting interested in this stuff goes) :)

    Anywhoo, the portion that you are looking for is marked out! The rest of this mess is me trying to be able to switch through various other screensavers without having to constantly open the window to pick the next one (I have a service through the automator where all you need is hit two keys to change ad it switches [this thankfully works... just can't get the pretty pictures]). It was looking promising but I am running into a glitch with OS X 10.9's Random option. It seems to just want to only pick the same one over and over again. The code down here is now giving me nothing but a grey screen. So, if you know any other ways to either randomly choose one through the script itself or perhaps there is another version of the randomized screensaver floating around for a download I would be more than grateful if you could link me over.

    Code:
    %%%%%%%%%%%%%%%%%%FLUFF%%%%%%%%%%%%%%%%%
    
    tell application "ScreenSaverEngine"
    	quit
    end tell
    
    tell application "System Events"
    	set ss to screen saver "random"
    	tell application "ScreenSaverEngine"
    		quit
    	end tell
    end tell
    
    %%%%%%%%%%%%%%%%%FLUFF%%%%%%%%%%%%%%%%%%
    
    %%%%%%%%%%%%%%%%NOT FLUFF%%%%%%%%%%%%%%%%%
    
    tell application "System Events"
    	if process "ScreenSaverEngine" exists then
    		tell application "ScreenSaverEngine" to quit
    	else
    		do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background > /dev/null 2>&1 &"
    	end if
    end tell
    
    %%%%%%%%%%%%%%%NOT FLUFF%%%%%%%%%%%%%%%%%%
    
    
    Sorry for the wall of text but kinda just decided at the beginning of the week that this was my challenge and have been working my rear off to figure this out. Its been a blast. Next up is to see if I can add more fluff that goes ahead and makes the shortcut keys for you as well as gives you a few more desktop friendly screensavers to choose from.

    [BONUS PRETTY PICTURE]

    http://imgur.com/vdGNAgn
     
  3. PacSoc macrumors newbie

    Joined:
    Feb 20, 2014
    #3
  4. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    Sorry to break it to you but it's 2014. ;) Here's an example of what you can do with UI scripting. The script will cycle through the screensavers in the Desktop & Screen Saver window of System Preferences on Leopard. It probably doesn't work on Mavericks but if you can spare a few minutes I'll give one that does.


    Code:
    tell application "System Preferences"
    	-- insert actions here
    	activate
    	reveal anchor "ScreenSaverPref" of pane id "com.apple.preference.desktopscreeneffect"
    end tell
    
    tell application "System Events"
    	tell process "System Preferences"
    		-- insert GUI Scripting statements here
    		set theRows to rows of outline 1 of scroll area 1 of group 1 of tab group 1 of window "Desktop & Screen Saver"
    		repeat with i from 2 to 19
    			if i is not 10 then
    				set aRow to item i of theRows
    				set selected of aRow to true
    				delay 1
    			end if
    		end repeat
    	end tell
    end tell
    
     
  5. PacSoc macrumors newbie

    Joined:
    Feb 20, 2014
    #5
    Got the Fluff Working

    So on my end it is finally working like I would like it to. I went ahead and gave up on OS X's version of random and figured out how to randomly pull one variable from a list. There are redundancies here of course but its the only way I was able to get it to cooperate with me. If anyone has ideas on how to improve it I am all ears.
    Code:
    
    ##This quits background app and gets ready for new screen saver##
    
    tell application "ScreenSaverEngine"
    	quit
    end tell
    
    tell application "System Events"
    	set myList to {"Flurry", "Arabesque", "Shell", "nfsSimpleWoodClock", "Strands", "Fliqlo"}
    	set screenSaver to some item of myList
    	set ss to screen saver (screenSaver)
    	tell application "ScreenSaverEngine"
    		quit
    	end tell
    end tell
    
    #######This puts screen saver as wallpaper#########
    
    tell application "System Events"
    	if process "ScreenSaverEngine" exists then
    		tell application "ScreenSaverEngine" to quit
    	else
    		do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background > /dev/null 2>&1 &"
    	end if
    end tell
     
    
    
    View attachment Screen Saver To Wallpaper.zip
     
  6. PacSoc macrumors newbie

    Joined:
    Feb 20, 2014
    #6
    Hehehe... Bit too scared of the UI stuff to be honest. Though I am excited to see what you post for Mavericks, because it will probably wind up being something I refer to quite a bit.
     

Share This Page