• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Applescript and Mission Control
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript and Mission Control


  • Subject: Re: Applescript and Mission Control
  • From: Robert Poland <email@hidden>
  • Date: Tue, 26 Nov 2013 10:44:47 -0700

2551,

Got a working script now. Only on one monitor for now.

(* set_Spaces - 11/25/13 *)

-- pick a new background image
set theFile to choose file
delay 1
-- log "theFile = " & theFile

-- Find out how many spaces/desktops you have
tell application "System Events"
	tell application "System Preferences"
		reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
		delay 0.5
	end tell -- application "System Preferences"
end tell -- application "System Events"

tell application "System Events"
	tell process "System Preferences"
		activate
		tell window 1 -- "Keyboard"
			select (row 3 of table 1 of scroll area 1 of splitter group 1 of tab group 1)
			set numSpaces to count (UI elements of rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1 whose name begins with "Switch to Desktop")
		end tell -- "Keyboard"
	end tell -- process "System Preferences"
	tell application "System Preferences" to quit

end tell -- System Events
-- log "numSpaces = " & numSpaces
delay 1

tell application "System Events" to key code 18 using {control down} -- Desktop 1
repeat (numSpaces) times
	tell application "System Events"
		tell current desktop
			set picture to theFile
			beep
		end tell
		delay 1

		-- switch to the next desktop
		-- *Note:* Set your keyboard shortcut for "next desktop" if it's different
		tell application "System Events" to key code 124 using {control down} -- ^→
		delay 1
	end tell -- application "System Events"
end repeat
beep 2


On Nov 22, 2013, at 7:36 AM, 2551 <email@hidden> wrote:

> Sorry Robert. Scrub that. I should have tested it on Mavericks first — no go I’m afraid.
>
> They must have changed the defaults command. I’ll see if I can figure out what to over the weekend.
>
> On 22 Nov 2013, at 21:28, Robert Poland <email@hidden> wrote:
>
>> Thanks 2551,
>>
>> I’ll try to figure that out later, after work.
>>
>> On Nov 22, 2013, at 7:08 AM, 2551 <email@hidden> wrote:
>>
>>> I’m not sure if I understand you correctly. Do you mean you want to change all the Desktop/Spaces to display the same background image?
>>>
>>> If so, I wrote a bash script to do that back in 10.7. You could convert it to an applescript by running the ‘defaults write’ line from a ‘do shell script’ instead.
>>>
>>> Note, it only work on one monitor at a time. I never did solve the problem of getting it to work across monitors.
>>>
>>> -----------------------------------------------------------------------
>>> #! /bin/bash
>>> #script to change all desktop backgrounds
>>>
>>> echo "Drag and drop an image file here"
>>> echo -n "then press return or press control-c to cancel..."
>>>
>>> read -e WLPR;
>>>
>>> function change_wallpaper
>>> {
>>> defaults write com.apple.desktop Background "{default = {ImageFilePath='$WLPR'; };}"; killall Dock
>>> }
>>>
>>> change_wallpaper
>>>
>>> #EOF
>>>
>>> -----------------------------------------------------------------
>>>
>>> On 22 Nov 2013, at 20:21, Robert Poland <email@hidden> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am just getting into Mission Control.
>>>>
>>>> It’s annoying to me that the Desktop has different images in different Spaces
>>>>
>>>> Is there any reasonable way for Applescript of switch these images?
>>>>
>>>> I see that Mission Control has no Applescript dictionary.
>>>>
>>>> TIA,
>>>>
>>>>
>>>> Robert Poland
>>>> iMac, Mid 2011, 12,2
>>>> 2.7 GHz Intel Core I5, 27”
>>>> 12 GB Ram, 1TB HD
>>>> OS X 10.9

Robert Poland - Fort Collins, CO




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >Applescript and Mission Control (From: Robert Poland <email@hidden>)
 >Re: Applescript and Mission Control (From: 2551 <email@hidden>)
 >Re: Applescript and Mission Control (From: Robert Poland <email@hidden>)
 >Re: Applescript and Mission Control (From: 2551 <email@hidden>)

  • Prev by Date: Re: AppleScript Reference Library
  • Next by Date: Re: file with most recent modification date
  • Previous by thread: Re: Applescript and Mission Control
  • Next by thread: Paths from my Mac, hidden, compiled into my script?
  • Index(es):
    • Date
    • Thread