It is easy to hammer in ut while not pushing any buttons.
First co to configure controls.
Scroll down a bit where you have the stand still with the first key as shift.
Select the 2nd button on the right and assign your #7 from the keypad as the second key (under your Num Lock key)
When you are in window mode just make sure you stand in the right spot press and hold your #7 key (under the numlock and press your num lock key to turn num lock off while holding your #7 key) when you done this you should be able to click anywhere in the screen and you will start to hammer without moving. Just hold your mouse button and slide your mouse outside of the window. If done correctly you can release your mouse button. To stop it just turn on your num lock again and click.
This should work. I suggest that you try it in a random game before doing it in a ut so you don't f*ck it up

.