You will need something like Windows Hook. You will have to look more into WIndows API for that to do.