I have a problem with desktop clean up. Put simply, nothing works. I have the following snippet which does half the job.
After a bit of script which checks if the the enable assistive devices box in system prefs is checked, the first half of the script appears to do nothing until you click on the desktop and then on menu bar 1: Then it all cleans up nicely. The second part of the script effectively brings the desktop window to the fore, but I still have to manually click on any blank prt of the menu bar. I have tried all sorts of ways to script this, but nothing works. Any suggestions?
tell application "System Events"
set UI_enabled to UI elements enabled
end tell
if UI_enabled is false then
tell application "System Preferences"
activate
set current pane to ¬
pane "com.apple.preference.universalaccess"
set the dialog_message to "This script utilizes " & ¬
"the built-in Graphic User Interface Scripting " & ¬
"architecture of Mac OS X " & ¬
"which is currently disabled." & return & return & ¬
"You can activate GUI Scripting by selecting the " & ¬
"checkbox "Enable access for assistive devices" " & ¬
"in the Universal Access preference pane."
display dialog dialog_message buttons {"Cancel"} ¬
default button 1 with icon 1
end tell
end if
end
tell application "System Events"
activate
set frontmost to true
click menu item "kind" of menu "Arrange By" of menu item "Arrange By" of menu "View" of menu bar item "View" of menu bar 1 of application process "Finder" of application "System Events"
end tell
tell application "Finder"
activate
set visible of every process whose visible is true and name is not "Finder" to false
delay 2
end tell