If this can be done at all, it would be through the Java Robot class.
I would not expect it to be possible, though, as it would then be too easy for a user program to capture passwords intended for a different program.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!