Re: Finder Window Position Help
Re: Finder Window Position Help
- Subject: Re: Finder Window Position Help
- From: kai <email@hidden>
- Date: Tue, 9 Jan 2007 23:38:32 +0000
On 9 Jan 2007, at 15:50, revDAVE wrote:
BTW: I did it try to add the toolbar visible lines to the top
script - but
they did not seem to do anything - so I kept kai's second script
intact
Hi Dave.
Think of using the toolbar visible lines to perform a kind of save.
So you set up the window the way you like, and then store the
settings by toggling the toolbar. So that particular code needs to be
executed at the end of your script.
set toolbar to not toolbar visible of Finder window 1 - hmmm?
set toolbar to toolbar visible of Finder window 1 - hmmm?
It does seem a little weird, I grant - but it's just a way to avoid
conditional tests. Another (perhaps more conventional) approach it
might be:
------------------
if toolbar visible then -- currently true
set toolbar visible to false -- store window settings
set toolbar visible to true -- restore user pref
else -- currently false
set toolbar visible to true -- store window settings
set toolbar visible to false -- restore user pref
end if
------------------
However, the script doesn't really care whether the current value is
true or false - only that it needs to switch the setting twice; once
to store the window settings, and then a second time to restore the
user's toolbar preference (whatever it might have been). Applying the
logical operator 'not' simply reverses the Boolean value; not true is
false, not false is true.
If you recall, the relevant part of my suggestion went like this:
------------------
case 1 case 2
------ ------
set v to toolbar visible true false
set toolbar visible to not v false true
set toolbar visible to v true false
------------------
Yet another approach could reduce the code to a couple of lines:
------------------
set toolbar visible to not toolbar visible
set toolbar visible to not toolbar visible
------------------
However, this is a bit less efficient since, in addition to a couple
of set commands, it also involves two 'gets' - one more than either
of the above methods. (Try running them in Script Editor, with the
Event Log visible, to see what I mean.)
tell application "Finder"
activate
select Finder window 1
set current view of Finder window 1 to list view
set bounds of Finder window 1 to {5, 45, 1000, 900}
set width of column id name column of list view options of
Finder window
1 to 299
set width of column id modification date column of list view
options of
Finder window 1 to 190
set width of column id size column of list view options of
Finder window
1 to 99
set width of column id kind column of list view options of
Finder window
1 to 153
end tell
tell application "Finder"
activate
tell Finder window 1 to if exists then
set v to toolbar visible
set toolbar visible to not v
set toolbar visible to v
close
end if
end tell
Q: Any idea how to combine the two scripts?
- - -
Sure. Something like this should do the trick:
------------------
tell application "Finder"
activate
tell Finder window 1 to if exists then
set bounds to {5, 45, 1000, 900}
set current view to list view
tell its list view options
set width of column id name column to 299
set width of column id modification date column to 190
set width of column id size column to 99
set width of column id kind column to 153
end tell
set v to toolbar visible
set toolbar visible to not v
set toolbar visible to v
close
end if
end tell
------------------
---
kai
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden