How to capture text from the operating system in a practical and simple way?

Sometimes we can't select the text to copy & paste, such as dialog boxes.

Sometimes it's just not practical, such as 100 files inside a folder.

Is there any practical and simple way to capture those text from the system into a text file?

I'd wish to know both in OS X and Windows. Maybe it just can't be done today...


On OS X you can use Accessibility Inspector (in /Applications/Xcode.app/Contents/Applications/):

⌘F7 locks the currently focused element and ⌘C copies the value of the selected row.

You can also run a script like this in AppleScript Editor:

tell application "System Events" to tell process "Safari"
    value of UI elements of UI elements of window 1
end tell

Then copy the result text:

{{}, {}, {}, {missing value, false, missing value, true}, {missing value}, {}, {"windows - How to capture text from system - Super User"}, {missing value, missing value, missing value, missing value}}