Re: desktop picture
Re: desktop picture
- Subject: Re: desktop picture
- From: kai <email@hidden>
- Date: Fri, 13 Jan 2006 22:02:38 +0000
On 12 Jan 2006, at 18:22, Willem Perquin wrote:
UI scripting is handy for a whole bunch of stuff, Willem - but in
this case, there's a rather easier and better way to achieve the
same result:
.... and...
The 'random' settings don't affect the static desktop image. All
it does is tell Dock.app to draw a new image layer on top the
static desktop picture. This is why, after setting a desktop
image with applescript, you won't see the image until you uncheck
the 'Chang picture' option in system preferences. It would be
interesting to learn how exactly System Preferences
But I dont want to uncheck the 'Change picture'.
I don't think Mike was suggesting that you do, Willem. He was
answering Nigel's question.
I do not want one picture but want to select the folder 'abstract'
in one script and 'nature' in the other script, with the 'change
picture' selected.
I'm afraid that wasn't clear (to me, at least) from your original
post. If I now understand you correctly, you simply want to select an
image 'set' - regardless of whether or not the 'Change picture'
checkbox is checked. (Of course, if it happens to be unchecked, the
script would have no visible effect on the desktop.)
I have a script now and it works. And as you can see, not very
elegant so if there is a other way to do this, I am all ears.
tell application "System Events"
if UI elements enabled then
click menu item "Bureaublad en schermbeveiliging" of menu
"Weergave" of menu bar 1 of process "System Preferences"
keystroke tab using {shift down} -- forward tab key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
keystroke (ASCII character 30) -- up arrow key
--De bovenste is nu geselecteerd, nu naar beneden in de lijst.
Natuur staat op de tweede plaats, abstract op 5, dus dan 4 keer
kopieren
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
else
tell application "System Preferences"
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is niet aan. Vink
\"Activeer toegang voor hulpapparaten\" aan"
end tell
end if
end tell
I'd be slightly concerned (as I suspect you may be, too) about the
potential brittleness of all those up and down arrow key strokes. In
addition, your script could fail if radio button
"Schermbeveiliging" ("Screen Saver"), rather than
"Bureaublad" ("Desktop"), had been selected previously in System
Preferences.
The following script aims to achieve a similar result, while
attempting to address these issues - and the question of localisation:
--------------
to useImageSet(imageSet)
tell application "System Events"
if not UI elements enabled then
tell me to display dialog "GUI Scripting must be enabled to run
this script. " & ¬
"(This may require you to enter your account password.)" & ¬
return & return & "Enable GUI Scripting?"
set UI elements enabled to true
if not UI elements enabled then error number -128
end if
set quitApp to not (exists process "System Preferences")
end tell
tell application "System Preferences" to ¬
set current pane to pane "com.apple.preference.desktopscreeneffect"
tell application "System Events" to tell tab group 1 of ¬
window 1 of application process "System Preferences"
tell radio button 1 to if value is 0 then
click
repeat while value is 0
delay 0.1
end repeat
end if
select (first row of table 1 of scroll area 2 of group 2 of ¬
group 1 whose value of first static text is imageSet)
end tell
if quitApp then tell application "System Preferences" to quit
end useImageSet
useImageSet("Abstract")
--------------
However, I believe this, too, can be achieved more elegantly by means
other than GUI scripting. For example:
--------------
to useImageSet(imageSet)
if imageSet starts with "Apple" then set imageSet to ""
set changePath to POSIX path of (path to desktop pictures folder) &
imageSet
set plistPath to POSIX path of (path to preferences from user
domain) & "com.apple.desktop.plist"
tell application "System Events" to tell property list item 1 of
property list item "Background" of ¬
property list file plistPath to set value of property list item
"ChangePath" to changePath
end useImageSet
useImageSet("Abstract")
--------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden