Don't know what to tell you really, since I just grabbed HKN, copy pasted your script, loaded it and it works fine: https://youtu.be/TeVAk4IwRLA

Only thing I can come up with from the top of my head would be to make sure you are renaming the windows exactly correctly. I.e. WoW1, and not wow1.

I didn't test Mouse4 since I don't have one on my current mouse, but I don't see any reason why it would not work if space works just fine.