Refactorized screen capture.