You are not logged in.
Hi folks.
I'm trying to open a finder window with properties, but she doesn't want to take.
Applescript:
property myTarget : "/Users/rich/Documents/Scanned/"
tell application "Finder"
set myW to make new Finder window with properties {current view:list view, toolbar visible:true, target:myTarget}
end tell
The target isn't being taken for some reason. No errors, but it just won't go to the target I want.
Any ideas appreciated.
Cheers
Offline
Hi,
set the target in an extra line
Applescript:
set myTarget to (path to documents folder as text) & "Scanned:"
tell application "Finder"
set myW to make new Finder window with properties {current view:list view, toolbar visible:true}
set target of myW to myTarget
end tell
Note: AppleScript expects HFS paths (colon separated)
regards
Stefan
Offline
Ah very good. Why won't the object take the setter method with parameters? Neither target nor current view stuck as properties.
Cheers
Offline
It often happens that some initial properties can't be set with the 'with properties' parameter — not just with the Finder, but with potentially any application. The reason could be a technicality to do with the kind of object being 'made' or an oversight or idiosyncasy on the part of the developer.
However, the Finder's implementation of 'make' has a 'to' parameter, which can be used with either 'alias files' or 'Finder windows'.
Applescript:
set myTarget to (path to documents folder as text) & "Scanned:"
tell application "Finder"
set myW to make new Finder window to folder myTarget
tell myW to set {current view, toolbar visible} to {list view, true}
end tell
Or, if you don't need to refer to the window again in the script:
Applescript:
set myTarget to (path to documents folder as text) & "Scanned:"
tell application "Finder"
tell (make new Finder window to folder myTarget) to set {current view, toolbar visible} to {list view, true}
end tell
Last edited by Nigel Garvey (2011-06-14 02:56:56 am)
NG
Offline
Yes, those would be setter methods for an object oriented system. The instance of the object, given properties, should stick. I'd say this is a fault with something. Modifying properties after the object is made shows their onCreate methods lack proper attribute assignment.
LOL I never got AS syntax.
Cheers
Offline
Sorry to resurrect this old post, but I wonder: Did anybody find a solution by now?
Is it possible to set a Finder window's properties, such as view, target, icon size, bounds, etc. before making the widow?
Otherwise you can actually see the changes occur, which is somewhat inelegant.....
Thanks!
Offline
Sorry, nope you can't set properties of a finder window, or any window before you create it.
T.B
p a file peruser, work in progress, but is sane, and lets you copy the file you view to the clipboard. Enter just "p" for help. Slightly better terminal handling, when executing shell commands from within.
Offline
It is actually possible to set the view and view options before opening a window:
Applescript:
set myTarget to (path to documents folder as text) & "Scanned:"
tell application "Finder"
tell container window of folder myTarget
set current view to list view
set icon size of its list view options to large icon
open
set its bounds to {50, 50, 800, 800}
set its toolbar visible to true
end tell
end tell
NG
Offline
I'm sorry. I have never noticed the container window before. At least I can't recall having used it.
Thanks for showing that the toolbar visible still works. I was sure it was gone now,with the additions of the tabs.
T.B
p a file peruser, work in progress, but is sane, and lets you copy the file you view to the clipboard. Enter just "p" for help. Slightly better terminal handling, when executing shell commands from within.
Offline
This worked for me. It's somewhat of a preset, and it worked as a one-liner too. The new window is quickly modified even though it's properties (other than target) are not actually set prior to the window appearing. But the values are!
Applescript:
set myTarget to path to desktop folder as text
set myBounds to {5, 10, 50, 100}
set myZoomed to false --some item of {true, false} --
set myCollapsed to false --some item of {true, false} --
set myView to list view --some item of {list view, column view, icon view, flow view} --
set mySidebar to 150 --(some item of {0, 100, 200, 300}) --300 --
set {newWNDW, properties of newWNDW} to {make new Finder window, {target:myTarget, bounds:myBounds, zoomed:myZoomed, collapsed:myCollapsed, current view:myView, sidebar width:mySidebar}}
return properties of newWNDW
Model: Mac Pro, Yosemite
AppleScript: 2.7
Browser: Safari 601.2.7
Operating System: macOS 10.14
"Fail and fail until you fail to fail!" ~ http://www.theMrScienceShow.com
Offline
For me too, if I include the :
Applescript:
tell application "Finder"
end tell
Last edited by ldicroce (2019-04-17 02:07:23 am)
Offline