How to capture?

Hi!

        How can I write a program to capture the text of current
windows?