Hmmm! If you click on the desktop, CMD + J brings up a window that allows you to snap to grid or keep arrangement by name, date created, date modified, size, kind, and label. How one accesses that preference box is the mystery.
With a bit of GUI scripting it all becomes clear..
This script opens the View Options window and gets the status of whether the checkbox is ticked or not and then returns that in a dialog. With a little modification you could get the current cell of the popup.
-- If the "View Options" window is already open it errors out saying "checkbox isn't ticked"
global app_name global menu_name global menu_item global window_opened global checkbox_status
set app_name to "Finder" set menu_name to "View" set menu_item to "Show View Options"
my open_view_window() -- open the view dialog
if window_opened is true then -- check it opened ok my check_checkbox_ticked() -- check if the "Keep arranged by" checkbox is ticked or not else my error_dialog("Error with the window opened if statement") -- on error display dialog box end if
if checkbox_status is equal to "1" then my display_dialog("The Checkbox is ticked") else if checkbox_status is equal to "0" then my display_dialog("The Checkbox is not ticked") else my error_dialog("Error with the checkbox_status if statement") end if
on check_checkbox_ticked() try tell application "System Events" tell process app_name tell window "Desktop" set checkbox_status to value of checkbox "Keep arranged by" as string end tell end tell end tell on error error_message return false end try
end check_checkbox_ticked
on error_dialog(dialog_text) display dialog dialog_text end error_dialog
on display_dialog(dialog_text) display dialog dialog_text end display_dialog
on open_view_window() try -- bring the target application to the front tell application app_name activate end tell tell application "System Events" tell process app_name tell menu bar 1 tell menu bar item menu_name tell menu menu_name click menu item menu_item end tell end tell end tell end tell end tell set window_opened to true on error error_message set window_opened to false end try end open_view_window
Caius Durling
P.S. Anyone else find there is a tab issue when you paste applescript code into a mail message? I find anything I type after it looks as though its been tab - indented, but you can't delete the tab.. Strange. |