Domanda
Sto creando alcuni lanci di schermo e volevo centrare esattamente le finestre nello schermo. Qualche buon modo per farlo sul Mac? Ho trovato uno script Apple esempio (e alcuni schermi collegati) ma nessuno di essi supporta il "terminale" in verticale (anche se supportano le altre applicazioni in verticale).
Soluzione
Mi piace usare Taglia in più Per gestire Windows, una delle quali è un'opzione centrale sullo schermo. Buona fortuna.
Altri suggerimenti
Non sono sicuro se questo potrebbe fare anche quello che stai cercando, ma Divvy è anche un software ordinato per l'organizzazione di Windows.
Ti suggerisco di guardare lo screencast sul loro sito Web per vedere se fa quello che stai cercando, ma in pratica ha una griglia in cui puoi cambiare le dimensioni e la posizione della finestra più anteriore.
Puoi anche modificare la griglia che viene visualizzato per avere un controllo più fine sulle dimensioni delle finestre con cui stai lavorando.
Spero che sia di aiuto.
Kevin. Sono l'autore del post a cui hai collegato su incrementalismo.net.
Il motivo per cui la finestra del terminale si sposta in alto è solo un bug nel supporto AppleScript di Terminal.
Questa versione esegue il centraggio verticale e funziona attorno al bug del terminale:
tell application "Finder"
set screenSize to bounds of window of desktop
set screenWidth to item 3 of screenSize
set screenHeight to item 4 of screenSize
end tell
tell application "System Events"
set myFrontMost to name of first item of ¬
(processes whose frontmost is true)
end tell
try
tell application myFrontMost
set windowSize to bounds of window 1
set windowXl to item 1 of windowSize
set windowYt to item 2 of windowSize
set windowXr to item 3 of windowSize
set windowYb to item 4 of windowSize
set windowWidth to windowXr - windowXl
set windowHeight to windowYb - windowYt
if myFrontMost is "Terminal" then
set bounds of window 1 to {¬
round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
round ((screenHeight + windowHeight) / 2) rounding as taught in school, ¬
round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
round ((screenHeight + windowHeight) / 2 + windowHeight) rounding as taught in school}
else
set bounds of window 1 to {¬
round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
round ((screenHeight + windowHeight) / 2) rounding as taught in school}
end if
set the result to bounds of window 1
end tell
end try
Spero che questo aiuti, se non hai già pagato una delle altre opzioni. Ho anche aggiunto un commento Con questa soluzione alternativa al post originale.
Correzioni per:
- Il bug con il terminale
- Strani nomi di processi (Firefox-Bin)
- Dimensioni della barra dei menu e del dock
- Supporto AppleScript disabilitato in Anteprima
- Le finestre che sono quasi la larghezza / altezza saranno ridimensionate a tutta larghezza / altezza
Osservazioni:
rounding as taught in school
non è davvero necessario- il valore predefinito è
rounding to nearest
, che gira .5 al numero intero anche più vicino (ad esempio 22,5 a 22)
- il valore predefinito è
- Davvero, nomi variabili misto Anche qui?
Tuttavia, ci sono una dozzina di cose in più che potrebbero andare storte. La parte del dock non è davvero necessaria se ti nascondi sempre. (Ma se ad esempio orientamento = in basso, potresti voler impostare dth su dth - 4.)
-- defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool yes
tell app "Finder" to set {0, 0, dtw, dth} to bounds of window of desktop
set dtw0 to dtw
set dth0 to dth
tell app "System Events" to tell dock preferences
set hiding to autohide
set edge to screen edge as string
end tell
if hiding then
set docksize to 4
else
tell app "System Events" to tell process "Dock"
set sz to size in list 1
if edge = "bottom" then
set docksize to item 2 of sz
else
set docksize to item 1 of sz
end if
end tell
end if
if edge = "bottom" then
set dth to dth - docksize
else if edge = "right" then
set dtw to dtw - docksize
else if edge = "left" then
set dtw to dtw + docksize
end if
set a to (path to frontmost application as text)
try
tell app a
set b to bounds of window 1
set w to (item 3 of b) - (item 1 of b)
set h to (item 4 of b) - (item 2 of b)
if w > dtw0 - 40 then set w to dtw
if h > dth0 - 40 then set h to dth
set item 1 of b to {dtw - w} / 2
set item 1 of b to (dtw - w) / 2
set item 2 of b to (dth - h + 22) / 2
set item 3 of b to (dtw + w) / 2
set item 4 of b to (dth + h + 22) / 2
end tell
if app "Terminal" is frontmost then
tell app "Terminal" to set position of window 1 to b
else
tell app a to set bounds of window 1 to b
end if
end try
Se vuoi centrali esattamente (quindi in orizzontale e verticalmente), puoi usare l'esempio fornito nei commenti sul sito a cui hai collegato e adattare la risposta pubblicata a Questa domanda di stackoverflow.
Ho finito con questo:
tell application "System Events" to tell application "Finder"
set {posx, posy, screenWidth, screenHeight} to bounds of window of desktop
end tell
tell application "Terminal" to set {windowLeft, windowTop, windowRight, windowBottom} to bounds of window 1
set windowWidth to windowRight - windowLeft
set windowHeight to windowBottom - windowTop
set newBounds to {¬
((screenWidth - windowWidth) / 2), ¬
((screenHeight - windowHeight) / 2), ¬
((screenWidth + windowWidth) / 2), ¬
((screenHeight + windowHeight) / 2) ¬
}
set newPosition to {¬
((screenWidth - windowWidth) / 2), ¬
((screenHeight - windowHeight) / 2) ¬
}
tell application "Terminal" to set bounds of window 1 to newBounds
tell application "Terminal" to set position of window 1 to newPosition
Tieni presente che questo sarà centrato window 1
, quindi se ti capita di usare strumenti come Visiera, dovrai usare window 2
invece.
Un'alternativa è Mercurymover. La "finestra centrale" è una delle scorciatoie integrate.
Puoi spostare le finestre con scorciatoie, definire posizioni personalizzate e fare un po 'di più. Suggerimento: prova il file di preferenza per definire numeri di pixel personalizzati diversi da 1, 10, 100.
È costoso con $ 20, ma paga nel tempo. Comunque, c'è una prova della vecchia scuola ... Macupdate: Mercurymover