Keep Arranged By (icons)

I would like to write a script that, when run, would have the same effect as clicking on the desktop, navigating to menubar>View>ShowViewOptions>, and then setting the "Arrange by" field to the value of my choosing. I can't seem to make this happen using the "view options" and "arrangement" properties of finder because it has difficulty with the fact that the desktop is actually pointing to things that exist in AFS space. I'd like to get it done by way of menu tells since that has at least appeared to be more promising. Using tells, I can choose the "Show View Options" menu item, but I can't seem to access anything therein.
Here is my code:
tell application "Finder"
activate desktop
tell application "System Events"
tell process "Finder"
tell menu bar 1
tell menu bar item "View"
tell menu "View"
tell menu item "Show View Options"
get properties
get entire contents
end tell
end tell
end tell
end tell
end tell
end tell
end tell
In the above code, get properties does return the properties of the window, but get contents returns empty braces. Furthermore, I don't know what language I should use to refer to the menu item that contains the arrangement options.
I'd appreciate any help on the matter.
Message was edited by: Halling

You know, I was about to use the various window properties from *Finder's scripting dictionary*, but then I noticed that the *column view options* don't have an *arrange by* property. Since there is one in the *VIew Options* window (even though the menu item is grayed out) and it appears to work, I took another look.
The problem with getting at those popup menu items is that the menu doesn't really exist until you actually press the popup button. Then, those sneaky folks at Apple tend to do stuff like hide one item inside of another, or don't give names to items, or number items backwards from what it look like - you know, fun stuff. If you have the *Developer Tools* installed, there is a handy utility for looking at the various GUI elements at /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app, although it may still look like Greek.
Give this script a try (I threw in a general purpose MenuClick handler at no extra charge):
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
MenuClick at {"Finder", "View", "Show View Options"}
tell application "System Events" to tell front window of application process "Finder"
tell pop up button 1
perform action "AXPress"
tell menu item "Date Created" of menu 1 to perform action "AXPress"
(* 1 = Name
2 = Date Modified
3 = Date Created
4 = Size
5 = Kind
6 = Label *)
end tell
end tell
MenuClick at {"Finder", "View", "Hide View Options"}
end run
to MenuClick at MenuItems
click a menu item in an application (the application will be activated)
    the number of menu items is not fixed, but must be at least 3 (application, menu, item)
    the last menu item doesn't need to be exact, just close enough for a match - it can also be an integer
  parameters: MenuItems [list] -
item 1 [text]: the application name
item 2 [text]: the menu bar item name
item(s) 3+ [text]: the menu item(s)
returns [boolean]: true if successful, false if no match or error
try
set ItemCount to the count of the items in MenuItems
if ItemCount is less than 3 then error "MenuClick handler:  menu item list contains too few items"
set {appName, MenuName} to items 1 thru 2 of MenuItems
set MenuItem to the last item of MenuItems
tell application appName to activate
tell application "System Events" -- set up the menu path
set MyMenu to menu MenuName of menu bar item MenuName of menu bar 1 of application process appName
if ItemCount is greater than 3 then -- process any sub menu items
repeat with MyItem from 3 to (ItemCount - 1)
set MenuName to item MyItem of MenuItems
set MyMenu to menu MenuName of menu item MenuName of MyMenu
end repeat
end if
if class of MenuItem is integer then
click menu item MenuItem of MyMenu
return true
else -- look for a match in the target menu
repeat with MyItem in (get name of menu items of MyMenu)
if MyItem contains MenuItem then -- can also use 'begins with'
click menu item MyItem of MyMenu
return true
end if
end repeat
error "MenuClick handler:  menu item \"" & MenuItem & "\" not found" -- no match
end if
end tell
on error ErrorMessage number ErrorNumber
if (ErrorNumber is -128) or (ErrorNumber is -1711) then
return false -- user cancelled
else
error ErrorMessage number ErrorNumber
end if
end try
end MenuClick
</pre>
Edit: the above script only works in Icon and Column views (the only popup button in List view is for text size)

Similar Messages

  • Arrangement of icons in a folder not saving on reboot....

    Hello - I'm posting this here as recommended - didn't get an answer on another forum.
    Hi - first problem with my year old mac, and first question here. Apologies if this one has been answered already - I looked through a few pages of the forum, but not all of them.
    For some reason one or maybe 2 of my folders has stopped remembering how I've arranged the icons. This only happens when I restart the computer - otherwise the icons stay where they are. Also the background gets reverted to the default state on reboot. This only happens with my main hd folder - the one in the top right of the screen, and maybe my applications folder, although I haven't checked that one thoroughly.
    It could be that the ds.store file is getting hosed somehow on reboot - any ideas why this might be happening?
    This is a single user computer, btw.
    Steve

    Hi Again Steve!
    Same answer in other thread.
    See if this Making Finder window views persistent, authored by Scott Radloff, helps.
    Also, positioning icons, too close to the edge of the window, will cause them to reposition themselves on restart.
    Positioning them too close to each other, will cause this as well.
    Depending on how many icons are displayed, the Size of the icons, as well as the Text size & Label position can also factor in. Experiment with these settings.
    My folder icons usually do not reposition themselves, and this is how I have my View Options set.
    Icon size: 32 x 32
    Text size: 12 pt
    Label position: Bottom
    I have none of the following options selected.
    Snap to grid
    Show item info
    Show icon preview
    Keep arranged by
    A different configuration may work for you. Experiment with the options until you find something suitable.
    With the folder window open,
    From the Finder's Toolbar, position your cursor over "View" and pull down to "Show View Options", and click. Or use the Command + J keys.
    ali b

  • What happened to "Keep Arranged By" in Finder?

    I did a fresh install of Snow Leopard and overall I'm fairly happy with the improvements.
    I am however perplexed by some of the basic features from Leopard that have seemingly gone missing. The most frustrating so far is the disappearance of "Keep Arranged By <typpe> option in Finder. At present the only folder that stays auto-arranged for me is my applications folder, but all others are arbitrarily organized.
    Has this option moved somewhere else, or is there a way to re-enable it? I don't see it in the Finder preferences or Show View options.
    Also, when I do set the preferences for a given folder using View Options, it won't propegate to all other folders even after setting the Default option.
    Its frustrating as each folder is getting more and more disorganized as I work. Any suggestions?
    Much appreciated,
    ted

    What they are talking about is a little bit different. I have had a few folders set to Keep Arranged by, mostly it drives me crazy, but when you add something to a folder so set, it automatically pops into place and all icons are re-arranged to accommodate the new-comer. Further, if you resize the folder by dragging the corner all items automatically rearrange themselves to take up the available space while maintaining their order. This option is still available in Icon view for any folder--go to the View menu item, press the Option key, and "Arrange by" changes to "Keep Arranged by" which can also be accessed from the Action toolbar gear. Again, press and hold the Option key as you access it.
    Francine
    Francine
    Schwieder

  • Where is the "Arrange Document" Icon in Top Menu Bar in PS CS6?

    PS CS5 had icons in the top menu bar where the "Arrange Documents" icons were located.  Now I can only find them in the Window drop down list.  Are they still available in CS6?  It was nice not having to find them in the "Window" drop down list.

    Some UI (or is it UX, nowadays) genius at Adobe has reduced accessibility of frequently used features.
    If there are particular arrangements you often use, assign keystrokes to the menu items.

  • Arrangement of icons?

    I understand that I can move and arrange the icons within a page, but how do I move them one page to the other?
    I would like to organize them into Photo, Games, News etc, but can't figure out how to move them from their assigned spot to the spot I choose.
    Thanks in advance for suggestions.

    The same way you move them around the first page, but just move them off the edge of the page and they will move to the next page.
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf

  • I have updated Flash player twice but keep getting the icon box telling me to update?

    I have updated Flash player twice but keep getting the icon box telling me to update?

    @zeyoo,
    Please let us know your operating system and browser.
    Please see the following docs that has step-by-step instructions on installing Flash Player:
    Windows: http://helpx.adobe.com/flash-player/kb/installation-problems-flash-player-windows.html
    Mac: http://helpx.adobe.com/flash-player/kb/installation-problems-flash-player-mac.html
    Thanks,
    Sunil

  • Re-arrange launchpad icons

    Using Yosemite (10.10.1), how to re-arrange launchpad icons?
    The technique that worked in my earlier version on OS X is described in this article:
    http://www.maclife.com/article/howtos/how_navigate_organize_and_delete_apps_laun chpad
    That technique no longer works. After re-boot, the launchpad icons appear in the original order, with my changes thrown away.

    Hello again, johncla.
    Thanks for the update on your issue. If you've not seeing the above functionality, then due to the nature of your issue you may find more information by using another one of Apple's support resources - https://getsupport.apple.com/GetproductgroupList.action to get a more hands-on response.
    Cheers,
    Pedro.

  • Remote Desktop Re-arranging Desktop Icons

    I have a Windows 8.1 Pro desktop customized with the Control Panel | Personalization | Display option to smallest possible size for desktop icons.   This works well enough for a login by console.   
    As soon as I connect by Remote Desktop, the arrangement of icons on the desktop is completely scrambled.   Is there any way to remember the arrangement of desktop icons and have these be the same for both console and remote desktop connections to Windows
    8.1?
    Will

    Hi Will,
    "Dynamic scaling level update" is a new Windows 8.1 feature.
    Remote Dsktop Connection now also updates the scaling level in the remote session to match the client-side configuration. you must change it on the local PC and it will automatically be updated in the session.
    Karen Hu
    TechNet Community Support

  • Can I arrange my icons on my iPhone up

    How can I arrange my icons up &amp; down so they go around my screen photo

    You can not do so.

  • Re-arranging app icons

    Having trouble Arranging app icons and moving them from page to page

    Since wiggling the icons doesn't work, maybe a reset of your iPad would clear this.  Hold the home and on/off buttons down together for about 10 seconds till the Apple logo appears.  Then try the wiggling again.

  • How to keep MS excel icon in the dock at iMac of guest sharing account

    Dear All
    May i know how to keep MS excel icon in the dock at iMac of guest sharing account.
    Thank a lot
    Raymond

    It's normal for the Guest account to return to a default state after logging out. Applications can still be opened from the Applications & other folders.
    You can add things to the Dock, & make other changes, using Workgroup Manager 10.8
    although it's not especially intuitive or forgiving. Post again if you want to try it.

  • My desktop on my laptop keeps making my icons disappear and reappear

    My desktop on my laptop keeps making my icons disappear and reappear

    Sounds like your Finder is crashing. Are you running GoogleDrive?

  • Reverse Sort Order of "Keep Arranged By-" on Desktop

    Is there a method for reversing the sort order of arranged items on the desktop? When using "Keep Arranged By Date Created/Modified", newer items are placed at the top.
    How can I reverse this order (so newer items are placed at the bottom)?

    If you have a two button mouse just click on the Desktop, then right click to bring up the contextual menu. You can also hold the control key and do a regular click to get the menu. The last item on the contextual menu is "Show View Options"--select it. The view options pane will open, and the last item in it is "Arrange by:" with a drop down list. Click the little arrows to bring up the list of various arrangements. The very first one is None, which is what I prefer. Select it and then arrange things the way you want them by hand.
    Francine
    Francine
    Schwieder

  • Arranging app icons and keeping them in place

    Every time apps are updated they get moved. How do we permanently keep each in place?

    Update through iTunes. It's safer anyway and takes less time (at least with the 2.1)
    Hope this helps.

  • Question about sysprep re-arranging desktop icons

    I can deploy my windows 7 image just fine, the copy profile is working as well, but I have setup the icons a specific way on the desktop on a couple of my images, and after deployment they always go back to the standard looking rows, and I lose all the customization
    of the desktop icons that I set up.
    Is there a way to tell sysprep or is there something I can do in the task sequence to keep my nice desktop icon customizations, and not have it go back to the standard rows after imaging?

    Hi,
    You could check the thirt-party below.
    "If you want to email the arrangement to someone or if you simply want to export it from the program, then you can also easily do that by saving the arrangement in ‘.dok’ format. The ‘.dok’ files can be exported and imported by DesktopOK only.
    You can even register this extension for DesktopOK but for this you will need to grand Administrator Privileges to the software."
    http://www.thewindowsclub.com/desktopok-save-restore-icon-positions
    Note: Microsoft provides third-party
    contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
    Best Regards,
    Joyce

Maybe you are looking for