take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Peter Irbizon
Hello,

I wondered if this is possible with pygame - I would like to take screenshot of my desktop. It means, my pygame app should run in background and be able to take whole screenshot of any application/whole desktop (not just itself), even in fullscreen mode (of in opengl, directx, direct3d, sdl mode). 
Because I tried to achieve this with python GTK but app for example when I took screenshot of my desktop and some video player with direct3d were running, I got black rectangle in that screen position.

Is there any sample code for this please?
Many thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

DiliupG
As far as I know this is not directly possible with Pygame as it's focus is on the window it creates. But you can use another method to do what you want.

On 20 June 2017 at 12:35, Peter Irbizon <[hidden email]> wrote:
Hello,

I wondered if this is possible with pygame - I would like to take screenshot of my desktop. It means, my pygame app should run in background and be able to take whole screenshot of any application/whole desktop (not just itself), even in fullscreen mode (of in opengl, directx, direct3d, sdl mode). 
Because I tried to achieve this with python GTK but app for example when I took screenshot of my desktop and some video player with direct3d were running, I got black rectangle in that screen position.

Is there any sample code for this please?
Many thanks



--
http://www.diliupg.com

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Michael Lutinsky
In reply to this post by Peter Irbizon

> I took screenshot of my desktop and some video player with direct3d were

> running, I got black rectangle in that screen position.

 

I remember this pheonomena back from when I was doing DirectX/DirectShow development. That black rectangle where you had a video playing is a special region of the screen that allows YUV data to pass through the video buffer. In other words, they make all the RGB pixels 0,0,0 and overlay a YUV video through that black "hole". So there's nothing you can capture there.

~ Michael

 



On Tuesday, June 20, 2017 12:05:08 AM PDT you wrote:

Hello,


I wondered if this is possible with pygame - I would like to take screenshot of my desktop. It means, my pygame app should run in background and be able to take whole screenshot of any application/whole desktop (not just itself), even in fullscreen mode (of in opengl, directx, direct3d, sdl mode). 

Because I tried to achieve this with python GTK but app for example when I took screenshot of my desktop and some video player with direct3d were running, I got black rectangle in that screen position.


Is there any sample code for this please?

Many thanks


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Peter Irbizon
In reply to this post by DiliupG
Thank you. I saw that link already. Unfortunately, none of these method is able to do it (when another window is rendered via directx, opengl, ...). 

Dňa utorok, 20. júna 2017 9:47:38 UTC+2 DiliupG napísal(-a):
As far as I know this is not directly possible with Pygame as it's focus is on the window it creates. But you can use another method to do what you want.
Read this: <a href="https://stackoverflow.com/questions/2846947/get-screenshot-on-windows-with-python" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F2846947%2Fget-screenshot-on-windows-with-python\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi_wybZ3xp0yLbI6KJLeNUOlSW6g&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F2846947%2Fget-screenshot-on-windows-with-python\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi_wybZ3xp0yLbI6KJLeNUOlSW6g&#39;;return true;">https://stackoverflow.com/questions/2846947/get-screenshot-on-windows-with-python
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Martin Kühne
There appears to be a glReadPixels(0, 0, width, height, GL_RGB,
GL_UNSIGNED_BYTE, pixels) function for that purpose in the OpenGL C
library, maybe pyopengl has an equivalent function?

cheers!
mar77i
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Greg Ewing
Martin Kühne wrote:
> There appears to be a glReadPixels(0, 0, width, height, GL_RGB,
> GL_UNSIGNED_BYTE, pixels) function for that purpose in the OpenGL C
> library, maybe pyopengl has an equivalent function?

That will only give you a snapshot of your own OpenGL
drawing area, not anything else on the screen. Getting
a full screenshot will need help from the OS and be
very platform-dependent.

--
Greg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

Peter Irbizon
In reply to this post by Michael Lutinsky
Hi Michael, yes, I thought it is this reason. I read about som kind of "bypassing" video buffer but no idea how this can be done. :(

Dňa utorok, 20. júna 2017 21:38:55 UTC+2 Michael Lutinsky napísal(-a):

> I took screenshot of my desktop and some video player with direct3d were

> running, I got black rectangle in that screen position.

 

I remember this pheonomena back from when I was doing DirectX/DirectShow development. That black rectangle where you had a video playing is a special region of the screen that allows YUV data to pass through the video buffer. In other words, they make all the RGB pixels 0,0,0 and overlay a YUV video through that black "hole". So there's nothing you can capture there.

~ Michael

 



On Tuesday, June 20, 2017 12:05:08 AM PDT you wrote:

Hello,


I wondered if this is possible with pygame - I would like to take screenshot of my desktop. It means, my pygame app should run in background and be able to take whole screenshot of any application/whole desktop (not just itself), even in fullscreen mode (of in opengl, directx, direct3d, sdl mode). 

Because I tried to achieve this with python GTK but app for example when I took screenshot of my desktop and some video player with direct3d were running, I got black rectangle in that screen position.


Is there any sample code for this please?

Many thanks


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: take screenshots of desktop and any app running (even with direct3d, opengl, sdl, ...)

René Dudfield
In reply to this post by Peter Irbizon
Perhaps OBS will make you happy. https://obsproject.com/
Loading...