• 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
Re: Save and restore Finder Window setup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Save and restore Finder Window setup


  • Subject: Re: Save and restore Finder Window setup
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 07 Jul 2015 21:16:05 +0200


Le 07/07/2015 à 20:06, Christopher Stone <email@hidden> a écrit :

On Jul 07, 2015, at 08:28, Markus Ruggiero <email@hidden> wrote:
When that Finder window is frontmost the script should somehow register the tabs and their setup (folder, kind of view, window size and placement, etc) and store this "somewhere"

I want to be able to run a script later that presents the list of saved settings and allows me to select and restore such Finder window with all its tabs.
______________________________________________________________________

Hey Markus,

Finder scripting does not support tabs at all on OSX 10.9.5.

Discovery with System Events is not all that pleasant either...

---------------------------------------------------------------
tell application "Finder"
  set winName to name of front window
end tell

tell application "System Events"
  tell application process "Finder"
    set uiElementList to UI elements of tab group 1 of window winName
  end tell
end tell
---------------------------------------------------------------

On my system System Events is seeing the front window as window 2 for some reason, which is why I'm asking the Finder to identify it above.

More directly I suppose would be:

---------------------------------------------------------------
tell application "System Events"
  tell application process "Finder"
    tell (first window whose subrole is "AXStandardWindow")
      set uiE to UI elements
      set attr to attributes
      set attrVal to value of attributes
      set propsOfAXTitle to properties of attribute "AXTitle"
      set props to properties
    end tell
  end tell
end tell
---------------------------------------------------------------

I cannot say for certain if anything has improved in Yosemite or El Capitan, but I'll be much surprised if anything has substantively changed.

I'm about to upgrade to 10.10, so I'll be more current in a few days.

--
Best Regards,
Chris

Hello Chris

Working with Yosemite 10.10.4, I ran this short script :

tell application "Finder"
class of every window
log result --> (*information window, Finder window, Finder window*)
name of every window
log result --> (*Infos sur sourceFolder, dest, sourceFolder*)
end tell

tell application "System Events" to tell process "Finder"
subrole of every window
log result --> (*AXStandardWindow, AXStandardWindow, AXStandardWindow*)
name of every window
--> {"Infos sur sourceFolder", "dest", "sourceFolder"}
end tell

As you may see, it's one case where the Finder is more efficient than System Events.

It makes the difference between "Finder windows" displaying folder contents and "information window" which System Events doesn't identify.

In such a case, running your second script returns :
tell application "System Events"
tell application process "Finder"
tell (first window whose subrole is "AXStandardWindow")
set uiE to UI elements
log result --> (*scroll area 1 of window Infos sur sourceFolder of application process Finder, button 1 of window Infos sur sourceFolder of application process Finder, button 2 of window Infos sur sourceFolder of application process Finder, button 3 of window Infos sur sourceFolder of application process Finder, static text Infos sur sourceFolder of window Infos sur sourceFolder of application process Finder, image 1 of window Infos sur sourceFolder of application process Finder*)
set attr to attributes
log result
set attrVal to value of attributes
log result
set propsOfAXTitle to properties of attribute "AXTitle"
log result --> (*class:attribute, value:Infos sur sourceFolder, settable:false, name:AXTitle*)
set props to properties
log result
end tell
end tell
end tell

I'm not sure that it was what you really wanted to get.

I may use an alternate filter: tell application "System Events"
tell application process "Finder"
tell (first window whose subrole is "AXStandardWindow" and name does not contain "Infos")
log (get its name)
set uiE to UI elements
log result --> (*static text 38 éléments, 128,62 Go disponibles of window dest of application process Finder, splitter group 1 of window dest of application process Finder, button 1 of window dest of application process Finder, button 2 of window dest of application process Finder, button 3 of window dest of application process Finder, toolbar 1 of window dest of application process Finder, static text dest of window dest of application process Finder, image 1 of window dest of application process Finder*)
set attr to attributes
log result
set attrVal to value of attributes
log result
set propsOfAXTitle to properties of attribute "AXTitle"
log result --> (*class:attribute, value:dest, settable:false, name:AXTitle*)
set props to properties
log result
end tell
end tell
end tell

As I am really curious, I tested also :

tell application "Finder"
-- name of every window whose class is Finder window -- fail
-- name of windows whose class is Finder window -- fail
set wNames to name of every window
log result --> (*Infos sur sourceFolder, dest, sourceFolder*)
-- set wName to name of first window whose class is Finder window -- fail
set finderWindows to {}
repeat with i from 1 to count wNames
if class of window i is Finder window then set end of finderWindows to wNames's item i
end repeat
log finderWindows --> (*dest, sourceFolder*)
end tell
set found to false
repeat with i from 1 to count finderWindows
set wName to finderWindows's item i
repeat with j from 1 to count wNames
set maybe to wNames's item j
if maybe contains wName and maybe is not wName then
set found to true
exit repeat
end if
end repeat
if found then exit repeat
end repeat
log wName --> (*sourceFolder*)

tell application "System Events"
tell application process "Finder"
tell window wName
log (get its name) --> (*sourceFolder*)
set uiE to UI elements
log result --> (*static text 2 éléments, 128,58 Go disponibles of window sourceFolder of application process Finder, splitter group 1 of window sourceFolder of application process Finder, button 1 of window sourceFolder of application process Finder, button 2 of window sourceFolder of application process Finder, button 3 of window sourceFolder of application process Finder, toolbar 1 of window sourceFolder of application process Finder, static text sourceFolder of window sourceFolder of application process Finder, image 1 of window sourceFolder of application process Finder*)
set attr to attributes
log result
set attrVal to value of attributes
log result
set propsOfAXTitle to properties of attribute "AXTitle"
log result --> (*class:attribute, value:sourceFolder, settable:false, name:AXTitle*)
set props to properties
log result
end tell
end tell
end tell

Yvan KOENIG (VALLAURIS, France) mardi 7 juillet 2015 21:15:50



 _______________________________________________
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: Save and restore Finder Window setup
      • From: Christopher Stone <email@hidden>
References: 
 >Save and restore Finder Window setup (From: Markus Ruggiero <email@hidden>)
 >Re: Save and restore Finder Window setup (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Save and restore Finder Window setup
  • Next by Date: Re: Save and restore Finder Window setup
  • Previous by thread: Re: Save and restore Finder Window setup
  • Next by thread: Re: Save and restore Finder Window setup
  • Index(es):
    • Date
    • Thread