0

I would like to open 4 Finder windows and position them on my desktop. If possible, I would like to open each windows with another directory.

I had a solution for opening the 4 Finder windows. I was not able to open a specific (always the same) directory. Today for some reason, I get an error message.

tell application "Finder"

-- get number of open finders
set NumberofFinders to count every Finder window
if NumberofFinders is 0 then
    make new Finder window
    set the target of Finder window 1 to home
end if

-- close all finders except the frontmost one
if NumberofFinders is greater than 1 then
    repeat NumberofFinders - 1 times
        close last Finder window
    end repeat
end if

-- get screen info
set menueBarHeight to 24
set screenBounds to bounds of window of desktop
set screenWidth to item 3 of screenBounds
set screenHeight to (item 4 of screenBounds) - menueBarHeight

-- move finder and set the size
set the bounds of the front Finder window to {screenWidth * 0.5, screenHeight * 0.5 + menueBarHeight, screenWidth, screenHeight + menueBarHeight}

-- make 2nd finder
make new Finder window
set the target of Finder window 2 to home
set the bounds of the front Finder window to {0, screenHeight * 0.5 + menueBarHeight, screenWidth * 0.5, screenHeight + menueBarHeight}

-- make 3nd finder
make new Finder window
set the target of Finder window 3 to home
set the bounds of the front Finder window to {screenWidth * 0.5, screenHeight * 0, screenWidth, screenHeight * 0.5}

-- make 4nd finder
make new Finder window
set the target of Finder window 4 to home
set the bounds of the front Finder window to {0, 0, screenWidth * 0.5, screenHeight * 0.5}
-- bring the finders to the front
activate

end tell

Ergebnis: error "„Finder“ received an error: „bounds of window of desktop“ can n ot be read." number -1728 from bounds of window of desktop

gr8
  • 13
  • 2
  • `home` is a property of the application, you might try `path to home folder`. – red_menace Nov 04 '19 at 22:54
  • I copied and pasted your AppleScript code, as is, in Script Editor and ran it. It executed without error however the windows were not set to a location I'd choose but as mentioned in the other comment "`home` is a property of the application, you might try `path to home folder`". That said, you should also take into consideration the height of the Dock, if it's showing, and adjust the size of the windows so the lower two are not behind the Dock. – user3439894 Nov 05 '19 at 00:18
  • Use e.g. `tell application "System Events" to set dockHeight to item 2 of (get size of list 1 of process "Dock")` and change `set screenHeight to (item 4 of screenBounds) - menueBarHeight` to `set screenHeight to (item 4 of screenBounds) - (menueBarHeight + dockHeight)` Just a suggestion. – user3439894 Nov 05 '19 at 00:18
  • I tested your script as-is, and it worked fine on my machine under various conditions. no errors at all... I'm on Mojave (10.14.6). – Ted Wrigley Nov 05 '19 at 04:17
  • thanks for the tipps regarding `path to home folder`, this works. also the tipp regarding the dockHeight is useful. this all works on my macbook (catalina 10.15.1).. however, on the imac (catalina 10.15.1) i need it most, i get an error -1728 („bounds of window of desktop“ can not be read.") if i run the script. any tipps on that issue? thank you all – gr8 Nov 05 '19 at 05:22
  • i found some information in this forum that `Can’t get bounds of window of desktop. (-1728)` has to do with `The only way I can duplicate this error is if the Finder has the Quit Finder menu item enabled. Any chance you activated the Quit menu?`[https://stackoverflow.com/questions/11488126/get-bounds-of-desktop-with-applescript] and i indeed installed tinkertool and activated the option to add "Quit Finder" to finder and since then this error occurs. – gr8 Nov 05 '19 at 18:54

0 Answers0