1

I saw another question that sounds almost the same but the answers seem to be about whole desktop screen capture: DirectShow Source filter using Dekstop window as source.

I have looked at the PushSource and yes it does what it is meant to do, however I want the virtual webcam to grab a specific window (similar to how you can select to share a window in Skype's share screen).

How would I go about selecting a specific window as a capture for the virtual webcam? is there a specific method already in the DirectShow API that I don't know about that does this?

Community
  • 1
  • 1
Wilson1989
  • 63
  • 6
  • https://github.com/rdp/screen-capture-recorder-to-video-windows-free has options for specifying an HWND etc. – rogerdpack Jan 26 '13 at 19:11

1 Answers1

5

There is no specific method. Moreover the part of the sample that grabs from screen is already outside of DirectShow API, it is GDI instead.

So the solution is pretty simple, you GetWindowRect position of your window, and then grab from screen only this rectangle, not the whole desktop. Or instead, you can send WM_PAINT or WM_PRINTCLIENT to the window in order to request its paint into provided device context.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks for that. I had a look at the WM_PAINT and WM_PRINTCLIENT at the msdn dev center description for those. Im still confused on how i could modify the pushsource to grab the specific window. Im still kinda new to the whole Directshow+GDI libraries. I think that PRINTCLIENT is the way for me to go with this, the issue i find with this is the hwnd in the call, im not sure how to find out the HWND of the window i need (i kinda want to make it get a specific window and only that window, so i want to hard code it) – Wilson1989 Sep 27 '12 at 00:19
  • You have to get the `HWND` first. `FidnWindow` or something, you won't do it without `HWND`. – Roman R. Sep 27 '12 at 05:56
  • i had more of a read about HWND and found that its not constant (even while the program is running) ([hWnd Property](http://msdn.microsoft.com/en-us/library/aa979055%28v=vs.71%29.aspx)). Is there a way for me to force a specific HWND so that i can know exactly what HWND to look for? or another method to assure that the screen i want is the only one ever captured and recaptured even when the HWND is changed – Wilson1989 Sep 27 '12 at 11:06
  • Applications own windows so they might create and destroy them without checking with you. `HWND` is the handle to exiting window. While the window is alive, the `HWND` is constant. So you need to find it, then use it as long as it is good, then possibly looks for it once again if it is gone. – Roman R. Sep 27 '12 at 11:13