Take screenshot of all created spaces

Hello all,

I have an application where I take screenshots. However if I have multiple desktops (called spaces in macos world) I am not able to get screenshot of not active ones. Is there any way to loop through asll spaces?


Thanks in advance!