Below is a link for some fixes you can try. Skip the ones you've already tired. You may end up having to reinstall the operating system. Did your computer come with any CDs? Did you try a system recovery, that is, rebooting from the recovery partition, which has a clean copy of your OS. See if you have it, reboot the machine and start taping either the F10, or F11 key. When you see recovery manager, follow the prompts to restoring the computer to factory. How To Fix Error Code 31 (This device is not working properly because Windows cannot load the drivers required for this device)
Edit: If you do not have installation software, or a recovery partition. You can order it from HP. Just hold down the Ctrl and Alt keys, then press the "S" key. This will show you Model, serial, and product numbers. Then call HP support 1-800-474-6836. They can send you the Window 7 installation software. They can also help you get the computer up and running again for $25.00, I think that's the price.
But, if you want, I or one of our other members can assist you futher. Whatever works best for you.