how do i get the selected text, in the active window,

also how do i get all the text in the active window.

any help would be appreciated