views:

455

answers:

5

I am writing a sort of screen-recording app for Windows and wish to know when and which regions of the screen/active window have changed.

Is there a Windows API I can hook to get notified of screen changes?

Or would I need to manually write something like this? :(

I always figured that Remote Desktop used some sort of API to detect what regions of the screen had changed and only sent back those images - this is exactly the behavior that I need.

+1  A: 

I think Remote Desktop streams GDI like commands. I don't know how they capture them in the first place.

Lou Franco
+2  A: 

I don't think there is an API in Windows that can tell you which parts of the screen have changed.

One possible way is using a video mirror driver like UltraVNC uses.

Otherside
+3  A: 

I think you'll find some clues here Screen Event Recorder DLL/Application, here About Hooks, and here Writing a Macro Recorder/Player using Win32 Journal Hooks

boost
+2  A: 

It would seem that you're going to have to do a fair bit of work to detect screen changes. This posting at tech-archive.net for instance. With this you can copy to RAM a reference screen and then take another and compare the two. It'd be up to you to define what kind of a change is a meaningful one. It's similar material to this article on desktop capture.

boost
A: 

Thanks for your help everyone. I ended up writing an image differencing class which seems to calculate the changed rectangles suprisingly quick. I've posted the gist of how it works here.

At the moment I'm just doing it in a timer but planning to do it after input events too.

Thanks heaps for your links Boost - I've only just looked at this thread again so I'll check them out soon.

Ben Daniel