• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
System Events scripting of Finder window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

System Events scripting of Finder window


  • Subject: System Events scripting of Finder window
  • From: Doug McNutt <email@hidden>
  • Date: Fri, 16 Mar 2007 12:32:50 -0600

As a part of my login process, on an OS 10.3.9 G4, I open a window on my SE/30 file server which has been in use for 100 years or so. This script is part of the process which places the window on a small monitor that I use for the purpose. I want the Finder window to look like an OS 7 Finder window.

>	tell application "Finder"
>		activate
>		tell window "Transfer"
>			set current view to icon view
>		end tell
>	end tell
>	tell application "System Events"
>		tell process "Finder"
>			tell window "Transfer"
>				click button 1  -- Turns off the sidebars that make no sense in OS 7.
>			end tell
>		end tell
>	end tell
>	tell application "Finder"
>		set bounds of window "Transfer" to thebounds  -- a property saved in the Script APPL
>	end tell

I thought, this morning, that I would figure out how to sort the items by date modified. It seems that Finder can't be told to remember that setting for a window on an external volume without changing the setting for all windows.

Looking at the Element Inspector:

><AXApplication: "Finder">
> <AXMenuBar: "">
>  <AXMenuBarItem: "View">
>   <AXMenu: "View">
>    <AXMenuItem: "Arrange">
>     <AXMenu: "Arrange">
>      <AXMenuItem: "by Date Modified">
>
>Attributes:
>	SNIP
>   AXTitle:  "by Date Modified"
>	SNIP
>
>Actions:
>   AXCancel - cancels menu tracking
>   AXPick - selects a menu item
>   AXPress - selects a menu item

I tried this code with a bunch or textual changes and guesses. No version has worked.

>tell application "Finder"
>	activate window "Transfer"
>end tell
>tell application "System Events"
>	tell process "Finder"
>		click menu item "by Date Modified" of menu "Arrange" of menu item "Arrange" of menu "View" of menu bar ""
>	end tell
>end tell

Spelling in  Element Inspector helps not. It's "menu item", not "MenuItem" and it's "click" not "press". These are the options from System Events dictionary.

>click: cause the target process to behave as if the UI element were clicked
>	click  UI element  -- The UI element to be clicked.
>		[at  list]  -- when sent to a "process" object, the { x, y } location at which to click, in global coordinates
>	Result:   UI element  -- the reply for the command
>
>perform: cause the target process to behave as if the action were applied to its UI element
>	perform  action  -- The action to be performed.
>	Result:   action  -- the reply for the command
>
>select: set the selected property of the UI element
>	select  UI element  -- The UI element to be selected.
>	Result:   UI element  -- the reply for the command

So I really don't know if I should perform, click, select, press, pick, or something else but the code doesn't work. I also don't know if I need to tell the menubar (menu bar?) process something in Christmas-tree style. After a personally-assigned one hour time limit I have given up.

Can someone else suggest a correct syntax? A sample of something like what I'm trying to do?  I have to remain on 10.3.9 because I really need the SE/30 file server. There's a bunch of coding time invested there and Tiger refuses to connect.

--

--> From the U S of A, the only socialist country that refuses to admit it. <--
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: System Events scripting of Finder window
      • From: kai <email@hidden>
  • Prev by Date: Re: Quark - Find and Replace
  • Next by Date: Re: Getting at some Hidden Clipboard Contents
  • Previous by thread: Quark - Split out individual spread from a doc
  • Next by thread: Re: System Events scripting of Finder window
  • Index(es):
    • Date
    • Thread