Lo siguiente es un ejemplo de lo que haría, si necesitara ambos, para colocar un captura de pantalla en el portapapeles y guardarlo como archivo al mismo tiempo.
Yo usaría Automatizador para crear un Servicio 1 flujo de trabajo a la que un atajo de teclado podría asignarse, para ejecutar un AppleScript script para que estos dos acontecimientos se produzcan conjuntamente.
En Automatizador , crear un nuevo Servicio 1 con la siguiente configuración:
- El servicio recibe (sin entrada) en (cualquier aplicación)
- Añadir a Ejecutar AppleScript acción sustituyendo el valor por defecto código
con el ejemplo AppleScript código que se muestra más abajo:
- Guardar el Servicio de automatización 1 como, por ejemplo: Captura de pantalla al portapapeles y al archivo
- Asignar a acceso directo , en Preferencias del sistema > Teclado > Atajos > Servicios :
- Captura de pantalla al portapapeles y al archivo ⇧⌘5 2
Ahora, al pulsar ⇧⌘5 2 el cursor en forma de cruz aparece como si hubieras pulsado ⇧⌘4 Sin embargo, después de hacer el selección de forma normal y soltando el ratón, el zona seleccionada se copia a la vez en el portapapeles y guardado en un archivo en el Escritorio .
Actualización de MacOS Mojave:
- 1 En <strong>MacOS Mojave </strong>, a <em>Servicio </em>en <strong>Automatizador </strong>se llama ahora <em>Acción rápida </em>Así que selecciónalo.
- 2 Por defecto, <strong>⇧⌘5 </strong>en <strong>MacOS Mojave </strong>es mediante la asignación de una nueva función de captura de pantalla, así que intente <strong>⇧⌘6 </strong>en su lugar.
El convención de nomenclatura de archivos es la del MacOS por defecto para Capturas de pantalla guardado normalmente, en mi región. Es posible que tenga que ajustar la siguiente línea de código para que sea como en su región:
set theDateTimeNow to (do shell script "date \"+%Y-%m-%d at %l.%M.%S %p\"")
En mi región, este comando produce la siguiente salida de ejemplo donde el valor de la theDateTimeNow
variable sería, por ejemplo:
2018-01-13 at 12.04.30 PM
Entre la línea de código anterior y las dos líneas que le siguen en el script , producen, por ejemplo:
Screen Shot 2018-01-13 at 12.04.30 PM.png
En Terminal , eche un vistazo a la página de manual para ambos date
y strftime
para realizar ajustes en el formato de la fecha y la hora valor de la theDateTimeNow
variable según sea necesario o deseado.
Nota: Leer el comentarios a lo largo del ejemplo AppleScript código para entender lo que el script está haciendo.
Esto se probó bajo MacOS 10.13.1 y me ha funcionado sin problemas.
Ejemplo AppleScript código :
on run {input, parameters}
-- # Screen Shot to Clipboard and File
-- # Clear the clipboard so the 'repeat until isReady ...' loop works properly.
set the clipboard to ""
-- # Copy picture of selected area to the clipboard, press: ⌃⇧⌘4
-- # Note that on my system I need to keystroke '$' instead of '4'.
-- # I assume this is because the 'shift' key is being pressed.
tell application "System Events"
keystroke "$" using {control down, shift down, command down}
end tell
-- # Wait while user makes the selection and releases the mouse or times out.
-- # Note that the time out also acts as an escape key press of sorts. In other
-- # words, if the user actually presses the escape key it has no effect on this
-- # script like it would if pressing the normal shortcut outside of the script.
-- #
-- # As coded, the time out is 5 seconds. Adjust 'or i is greater than 10' and or
-- # 'delay 0.5' as appropriate for your needs to set a different length time out.
-- # This means, as is, you have 5 seconds to select the area of the screen you
-- # want to capture and let go of the mouse button, otherwise it times out.
set i to 0
set isReady to false
repeat until isReady or i is greater than 10
delay 0.5
set i to i + 1
set cbInfo to (clipboard info) as string
if cbInfo contains "class PNGf" then
set isReady to true
end if
end repeat
if not isReady then
-- # User either pressed the Esc key or timed out waiting.
return -- # Exit the script without further processing.
end if
-- # Build out the screen shot path filename so its convention is of
-- # the default behavior when saving a screen shot to the Desktop.
set theDateTimeNow to (do shell script "date \"+%Y-%m-%d at %l.%M.%S %p\"")
set theFilename to "Screen Shot " & theDateTimeNow & ".png"
set thePathFilename to POSIX path of (path to desktop folder as string) & theFilename
-- # Retrieve the PNG data from the clipboard and write it to a disk file.
set pngData to the clipboard as «class PNGf»
delay 0.5
try
set fileNumber to open for access thePathFilename with write permission
write pngData to fileNumber
close access fileNumber
on error eStr number eNum
try
close access fileNumber
end try
activate
display dialog eStr & " number " & eNum buttons {"OK"} default button 1 with title "File I/O Error..." with icon caution
end try
-- # Convert the POSIX path filename to an alias.
set thePathFilename to POSIX file thePathFilename as alias
-- # Hide the file extension as is the default.
tell application "Finder"
try
set extension hidden of thePathFilename to true
end try
end tell
end run
Nota: El ejemplo AppleScript código arriba es justo eso, y sin la inclusión tratamiento de errores no incluye ningún otro que pueda ser apropiado/necesario/querido, el usuario tiene la responsabilidad de añadir cualquier tratamiento de errores para cualquier código de ejemplo presentado y o código escrito por uno mismo.