Why is screencapture taking the screenshot of the desktop image and not the windows on top in Catalina?

I got same issue and finally found out what was wrong. Go to System Preference>Security & Privacy>Screen Recording, And give them permission to capture.

enter image description here


Starting with macOS Catalina, applications must be granted the ScreenCapture permission before they can capture any content from the screen. How do I configure Screen Recording permission on macOS Catalina? Normally when you run a command like screencapture you should be presented with an authorization prompt like this one:

If you don't see this prompt, you might need to reset your screen recording permissions for the Terminal application you are using: How do I reset Screen Recording permission on macOS Catalina?

tccutil reset ScreenCapture com.apple.Terminal

Instead of screencapture -s ~/Downloads/screen.png source where -s is for

Only allow mouse selection mode.

try -w. It will show a camera icon and wait for you to select a window. Hit esc to cancel the process.

screencapture -w ~/Downloads/screen.png

-w Only allow window selection mode.

I cannot say why -s doesn't work, but on Mojave, the man page says

The screencapture utility is not very well documented to date. A list of options follows.