Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Updated script to create dual Finder windows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Updated script to create dual Finder windows
Authored by: Chibby on Aug 21, '10 06:08:55AM
Had the same idea .. here u go:

set danswer to (do shell script "/usr/sbin/system_profiler SPDisplaysDataType | grep Resolution")
set monitor_width to (word 2 of danswer) div 1
set monitor_height to (word 4 of danswer) div 1
set hit1 to false
set hit2 to false
tell application "Finder"
activate
set window_count to the count of windows
repeat with i from 1 to window_count
try
if not hit1 then -- place first window / left
set the current view of window i to list view
set the bounds of window i to {40, 0, (monitor_width * 0.5) div 1 + 20, monitor_height}
set hit1 to true
if not hit2 then -- place second window / right
set the current view of onenewwin to list view
set the bounds of onenewwin to {(monitor_width * 0.5) div 1 + 20, 0, monitor_width, monitor_height}
set hit2 to true
exit repeat
end if
else -- if first window already placed - proceed with second / right window
set the current view of window i to list view
set the bounds of window i to {(monitor_width * 0.5) div 1 + 20, 0, monitor_width, monitor_height}
set hit2 to true
exit repeat
end if
end try
end repeat
if hit1 and hit2 then -- both windows already placed -> exit
else if hit1 then -- first / left window already placed - create second / right
set newwin to make new Finder window
set the current view of newwin to list view
set the bounds of newwin to {(monitor_width * 0.5) div 1 + 20, 0, monitor_width, monitor_height}
else if hit2 then -- second / right window already placed - create first / left
set newwin to make new Finder window
set the current view of newwin to list view
set the bounds of newwin to {40, 0, (monitor_width * 0.5) div 1 + 20, monitor_height}
else if not hit1 and not hit2 then -- create two new windows
set onehit to 2
set onenewwin to make new Finder window
set the current view of onenewwin to list view
set the bounds of onenewwin to {40, 0, (monitor_width * 0.5) div 1 + 20, monitor_height}
set twonewwin to make new Finder window
set the current view of twonewwin to list view
set the bounds of twonewwin to {(monitor_width * 0.5) div 1 + 20, 0, monitor_width, monitor_height}
end if
end tell


btw - there is a bug with creating the second window, if one already exists .. its this part from the code above (added to modified original hint):

...

else if hit2 then -- second / right window already placed - create first / left
set newwin to make new Finder window
set the current view of newwin to list view
set the bounds of newwin to {40, 0, (monitor_width * 0.5) div 1 + 20, monitor_height}

...


Big question .. this is the first time for me posting code here. .. how to format it?? It's really a pain using html "br"s all over the place... Thanks

[ Reply to This | # ]