Nido Apple

Recibe ayuda de expertos

Registrate y pregunta

Es gratis y fácil

Recibe respuestas

Respuestas, votos y comentarios

Vota y selecciona respuestas

Recibe puntos, vota y da la solución

Pregunta

1voto

Buenas noches.

He acomodado un script que pretende reordenar por nombre en cascada las ventanas abiertas del Finder.

Aunque lleva a cabo el reordenamiento, no lo hace de tal forma que sean visibles los nombres de todas las ventanas a pesar de estar ordenadas por nombre.

Por otro lado, cuando hay una ventana duplicada (mismo nombre) les asigna a ambas las mismas coordenadas en pantalla no formando parte del escalonamiento la ventana duplicada.

¿Cómo podría ajustar para que las ventanas se solapen de tal forma que todos los nombres de las ventanas sean visibles?

Gracias de antemano.

Salud.

He aquí el código:


set anchuraVentana to 930
set alturaVentana to 470
set solapamiento to 25

set xSupIzqFinder to 230
set ySupIzqFinder to 110
set xInfIzqFinder to xSupIzqFinder + anchuraVentana
set yInfIzqFinder to ySupIzqFinder + alturaVentana

--set xSupIzqChrome to 307
--set ySupIzqChrome to 40
--set xInfIzqChrome to 1491
--set yInfIzqChrome to 688

--tell application "Google Chrome" to activate
--tell application "Google Chrome" to set bounds of window 1 to {xSupIzqChrome, ySupIzqChrome, xInfIzqChrome, yInfIzqChrome}

tell application "Finder"
    set conjuntCarpetas to folder of every window

    -- Ordenar las carpetas por nombre
    set conjuntCarpetas to sort conjuntCarpetas by name

    -- Lista de límites para la primera ventana.
    set limitesDeVentana to {xSupIzqFinder, ySupIzqFinder, xSupIzqFinder + anchuraVentana, ySupIzqFinder + alturaVentana}

    -- Recorrer las carpetas
    repeat with unaCarpeta in conjuntCarpetas

        -- Apuntar al container window de la carpeta actual
        tell container window of unaCarpeta

            -- Configura los límites de la ventana a los límites nuevos
            set bounds to limitesDeVentana

            -- Desplazamiento hacia abajo de la ventana siguiente en la cantidad indicada en solapamiento
            set item 2 of limitesDeVentana to (item 2 of limitesDeVentana) + solapamiento
            set item 4 of limitesDeVentana to (item 4 of limitesDeVentana) + solapamiento
            set item 1 of limitesDeVentana to (item 1 of limitesDeVentana) + solapamiento
            set item 3 of limitesDeVentana to (item 3 of limitesDeVentana) + solapamiento

        end tell
    end repeat
end tell

Nota: Tras haber estado "funcionando" (con las limitaciones ya dichas), resulta que ahora, sin imaginar el motivo, ahora falla la compilación y queda detenida, en la línea:

set conjuntCarpetas to sort conjuntCarpetas by name

error "Finder ha detectado un error: No puede obtenerse alias file \"\"." number -1728 from alias file ""

:-((

Agradecería cualquier ayuda para comprender la situación y su posible solución.

Gracias. 
Salud.

1 Respuesta

1voto

Peter Puntos289100

Prueba con este Script.

-- Ask the user to enter some preliminary values for positioning and sizing the windows
set theTopOffset to askForInput("How many pixels would you like between the menu bar and the first window?", 10)
set theLeftOffset to askForInput("How many pixels would you like between the left of the screen and the first window?", 10)
set theWindowHeight to askForInput("How many pixels high would you like each window?", 300)
set theWindowWidth to askForInput("How many pixels wide would you like each window?", 350)
set theWindowOffset to askForInput("How many pixels would you like the windows offset from one another?", 25)
set staggerWindows to (button returned of (display dialog "Would you like the windows to cascade to the right?" buttons {"No", "Yes"} default button "Yes")) = "Yes"

-- Compensate for the menu bar
set theTopOffset to theTopOffset + 45

-- Get the parent folders of any opened windows
tell application "Finder"
    set theFolders to folder of every window

    -- Sort the folders by name
    set theFolders to sort theFolders by name

    -- Prepare the bounds list for the first window
    set theWindowBounds to {theLeftOffset, theTopOffset, theLeftOffset + theWindowWidth, theTopOffset + theWindowHeight}

    -- Loop through the folders
    repeat with aFolder in theFolders

        -- Target the container window of the current folder
        tell container window of aFolder

            -- Set the bounds of the window to the new bounds
            set bounds to theWindowBounds

            -- Offset the bounds of the next window down the appropriate amount
            set item 2 of theWindowBounds to (item 2 of theWindowBounds) + theWindowOffset
            set item 4 of theWindowBounds to (item 4 of theWindowBounds) + theWindowOffset

            -- If the windows should be staggered, offset the bounds of the next window right the appropriate amount
            if staggerWindows = true then
                set item 1 of theWindowBounds to (item 1 of theWindowBounds) + theWindowOffset
                set item 3 of theWindowBounds to (item 3 of theWindowBounds) + theWindowOffset
            end if
        end tell
    end repeat
end tell

-- Ask the user to enter a value
on askForInput(theQuestion, theDefaultAnswer)
    return text returned of (display dialog theQuestion default answer theDefaultAnswer)
end askForInput

0voto

DJUNQUERA comentado

Hola, Peter.

Muchísimas gracias por tu ayuda. :-))

Desgraciadamente _se produce el mismo error_ a la hora de compilar la línea del código que intenta ordenar por nombre las ventanas del Finder:

set theFolders to sort theFolders by name

error "Finder ha detectado un error: No puede obtenerse alias file \"\"." number -1728 from alias file ""

Me ha producido satisfacción el estudio del handler askForInput para introducir en una variable la respuesta del usuario a una pregunta y proporcionar una respuesta por defecto.

De nuevo mi agradecimiento.

Un abrazo.

Salud.

0voto

Peter comentado

Agrega en la primera linea:

tell application "Finder" to activate

Saludos.

Por favor, accede o regístrate para responder a esta pregunta.

Otras Preguntas y Respuestas


Actividad Reciente

...