Recording macros

I was just wondering if there are any programs that can record mousemovements/clicks, and then you can play them/loop them?

I think I’ve seen something like that before, but I don’t know…