I'm trying to automate a process that regularly changes my wallpaper. I'm naturally using the
Set Desktop Image action, with the "all screens" tag, because I want to change the wallpaper on all of my desktops. Strangely enough, it only changes the wallpaper of my main desktop. What am I doing wrong ? I'm new to KM so I might be missing something obvious...
Thank you for your help
I've never tried this action but whatever you are doing wrong, I'm doing the same thing because I can't get it to modify all of my screens either. You should report the bug by going to Keyboard Maestro Help > Report Bugs or Feature Requests to report the issue.
Thanks for your answer, I'll go ahead and report the possible bug.
I looked in to this and basically it will only work if you are on the first Space. Unfortunately, Apple doesn't make any of the Spaces API public, and it looks like this is some sort of relation to that. I also found in my testing that even the System Preferences gets somewhat confused about desktop images and spaces (showing a picture that I configured as a desktop for a space I had deleted).
Hello @whaaale Maybe I have that solution you are searching for .....
I am sorry @peternlewis, but as I said above I have the solution.... wrote this AppleScript a very long time ago - it took me a few days up to a whole week getting this working.... as always when I triggered it it worked perfectly (using macOS 10.13.6).
What I can say is that you are absolutely right that this will only work if Space 1 is selected. So in a Macro I would highly recommend that you should set the Macro up to simulate the Default Keystroke
⌃1 if its not changed - then a little pause
1-2 seconds and then this AppleScript with the
Execute an AppleSript - Action.... the rest of the Macro is up to your needs....
use AppleScript version "2.7" -- High Sierra (10.13) or later property ptyScriptName : "Change Background on 7 Spaces of Mission Control" property ptyScriptVer : "1.0" property ptyScriptAuthor : "Tobias Zittlau" (* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## CUSTOMIZABLE SECTION (Variables to set by ENDUSER) ## *) -- The Variable "thePic" should be set to the File-Path of the Picture to set as Desktop Background. set thePic to "~/PATH/TO/YOUR/PICTURE/INSERTED/HERE" -- The Variable "windowCount" for "Spaces" of Mission Control with defined number of Spaces. set windowCount to 7 -- Just an example Number of Spaces, set your Number of Spaces here (* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### BEGINNING OF SCRIPT ### PLEASE MAKE SURE OF SWITCHING TO DESKTOP 1 BEFORE CALLING THIS SCIPT, BECAUSE IT IS THE STARTING POINT FOR THIS SCRIPT-ROUTINE - OTHERWISE IT WILL NOT WORK PROPERLY !! ## Applications: System Events, Finder ## Variables set & used: deskGroup, theDesk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *) -- Telling "System Events" what to do tell application "System Events" -- Define the Variable "deskGroup" & set it as reference to existing Spaces set deskGroup to (a reference to every desktop) repeat with theDesk in deskGroup -- Change the Desktop Background Picture to the User´s selection set picture of theDesk to thePic end repeat end tell delay 1 -- 1 Second pause (giving time to get the Information) -- Performing the Routine in Finder (Trying!! Otherwise it won´t work!!). try repeat with X from 1 to windowCount tell application "Finder" tell application "System Events" if X > 1 then -- move to next Desktop with the Global Hot Key for Mission Control key code 124 using control down -- 1 Second pause - otherwise the Script will cause an error delay 1 end if -- set every Desktop to the selected Picture set deskGroup to (a reference to every desktop) repeat with theDesk in deskGroup set picture of theDesk to thePic end repeat end tell delay 1 end tell end repeat end try (* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### END OF SCRIPT ### *)
Just remember this is a ONE DESKTOP SOLUTION..... I don't know how to write it for more tan just one Desktop.
And before I forget it - be very careful if you want to edit the delays in the script... maybe the can be set to lower needs if you have a really fast Mac but they have to be set ! Otherwise the script will not work properly.
Hope this helps you and others...
Cheers - and have a nice Day and o lot of fun using this Script.
Greetings from Germany