Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
The "screencapture" command is a powerful tool available on macOS that allows users to take screenshots directly from the terminal. This can be particularly useful for automating screenshot tasks, creating scripts for documentation, or capturing screen content without using the graphical interface. In this article, we will explore how to use the "screencapture" command, provide practical examples, and discuss its various options and parameters.
Examples:
Basic Screenshot Command: To take a simple screenshot of the entire screen and save it to the desktop, you can use the following command:
screencapture ~/Desktop/screenshot.png
This command captures the entire screen and saves the image as "screenshot.png" on the desktop.
Capture a Specific Window:
If you want to capture a specific window, you can use the -l
option followed by the window ID. First, you need to find the window ID using the osascript
command:
osascript -e 'tell application "System Events" to get the id of every window of (every process whose frontmost is true)'
Once you have the window ID, use it with the screencapture
command:
screencapture -l <windowID> ~/Desktop/window_screenshot.png
Capture a Selected Portion of the Screen:
To capture a specific portion of the screen, use the -R
option followed by the coordinates and dimensions in the format x,y,width,height
:
screencapture -R0,0,800,600 ~/Desktop/portion_screenshot.png
This command captures an 800x600 pixel area starting from the top-left corner of the screen.
Capture with a Timer:
To delay the screenshot capture by a few seconds, use the -T
option followed by the number of seconds:
screencapture -T5 ~/Desktop/timed_screenshot.png
This command waits for 5 seconds before taking the screenshot.
Capture with Mouse Cursor:
To include the mouse cursor in the screenshot, use the -C
option:
screencapture -C ~/Desktop/cursor_screenshot.png
Capture and Open in Preview:
To capture a screenshot and immediately open it in the Preview application, use the -P
option:
screencapture -P ~/Desktop/preview_screenshot.png