It's been a while since I've used this, but I believe that you don't even have to have a window open to use those functions. However, I would advise not to use those functions, because some antiviruses pick them up as keyloggers. (My antivirus must be pretty stupid. It didn't catch anything.)
I would use the MSG loop to handle keyboard and mouse inputs; however, I don't believe that those work without focus on your window.