In the adb shell you can use command as
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
I found this code on this guide on How to take a screenshot on Android.You can refer it for more details.Hope this helps.