That's the same concept as a keylogger dude. Find one and look at the code.