PDA

View Full Version : Modificare Apple script


Eress
03-11-2015, 15:39
Mi servirebbe modificare uno script Apple in modo da ridimensionare sidebar e finestre Finder, ma senza centrarle nello schermo. Non sono molto esperto in materia :D
Lo script in questione è questo:

(*

This Apple script will resize any program window to an exact size and the window is then moved to the center of your screen.
Specify the program name, height and width below and run the script.

Written by Amit Agarwal on December 10, 2013

*)

set theApp to "Finder"
set appHeight to 412
set appWidth to 678

tell application "Finder"
set screenResolution to bounds of window of desktop
end tell

set screenWidth to item 3 of screenResolution
set screenHeight to item 4 of screenResolution

tell application theApp
activate
reopen
set yAxis to (screenHeight - appHeight) / 2 as integer
set xAxis to (screenWidth - appWidth) / 2 as integer
set the bounds of the first window to {xAxis, yAxis, appWidth + xAxis, appHeight + yAxis}
tell application "Finder" to set the sidebar width of every Finder window to 142
end tell


Ho modificato le dimensioni del Finder e aggiunto in fondo la riga della sidebar. Lo script funziona, ma vorrei come detto, eliminare la parte che centra le finestre del Finder nello schermo. Ho provato a modificare le righe in basso o eliminarle del tutto, ma così si ridimensiona solo la sidebar, mentre sulle finestre non funziona più. Qualcuno esperto di script saprebbe come fare?

superlex
04-11-2015, 01:10
Ciao :)
Esattamente, dove vorresti che venisse messa?
Per esempio così

set theApp to "Finder"
set appHeight to 412
set appWidth to 678

tell application theApp
activate
reopen
set yAxis to 100 as integer
set xAxis to 100 as integer
set the bounds of the first window to {xAxis, yAxis, appWidth + xAxis, appHeight + yAxis}
tell application "Finder" to set the sidebar width of every Finder window to 142
end tell

puoi cambiare il "100" a seconda di dove tu voglia posizionarla..

Eress
04-11-2015, 05:19
Allora vedi che avevo ragione, sei un esperto di OS X :p
Grazie della dritta, il tuo script funziona, ma come temevo non è possibile eliminare la posizione. Il fatto è che poi aprendo due o tre cartelle in sequenza e utilizzando lo script finiscono per sovrapporsi in modo innaturale e scomodo, rispetto al comportamento normale, dove sono leggermente sfalsate e quindi visibili/cliccabili. Del resto il Finder a differenza della sidebar inserita in esso, è un elemento fluttuante e quindi immagino sia obbligatorio inserire la posizione nello script. Forse servirebbe aggiungere qualcosa allo script per l'apertura di eventuali altre cartelle, se si può fare.

superlex
04-11-2015, 14:19
set theApp to "Finder"
set appHeight to 412
set appWidth to 678

tell application theApp
activate
reopen
tell application "Finder" to set the sidebar width of every Finder window to 142
end tell

tell application "System Events"
tell process theApp
set size of window 1 to {appWidth, appHeight}
end tell
end tell

Così? :D
Devi però andare in Preferenze di Sistema -> Sicurezza e Privacy -> Accessibilità -> Privacy e spuntare Script Editor.app

Eress
04-11-2015, 14:30
Perfetto! Ti sei meritato ufficialmente il titolo di esperto OS X honoris causa! :asd: :D

superlex
04-11-2015, 14:46
Ahahahah :p
Ho trovato tutto su Internet :)

Eress
04-11-2015, 14:51
Ahahahah :p
Ho trovato tutto su Internet :)
Beh allora sei un asso nella ricerca, io non l'avevo trovato :D
Grazie e ciao.

PS: e magari passami il link :D

superlex
04-11-2015, 14:56
Beh allora sei un asso nella ricerca, io non l'avevo trovato :D
Grazie e ciao.

PS: e magari passami il link :D

https://gist.github.com/rfunduk/6313009

Figurati :cincin:

Eress
04-11-2015, 16:22
Rigrazie :)
:cincin: