OK, it’s not really a hammer. It’s more like a pressure gun. MacGyver hooks up a pressured line from a water heater to a tube with a rod in it. When the pressure is released, it shoots the rod and hits the door handle to knock it out. That’s great.
If you want it to “hammer” back and forth, you need to do something different. Here is a very basic design.