From your question, I must assume that if you are using the system, it will run for hours with no problems. If this is the case, then you can rule out an overheating problem, such as a failing or blocked fan.
Under this premise, to help identify the problem, you will need to determine exactly when the system freezes. To do this, re-boot the system and let it sit for 20 minutes (or for an amount of time you are sure a lockup will occur). Try the mouse. If it is locked up, reboot and wait 15 minutes (or a time shorter than than the initial time). If it is locked up, reboot and wait 10 minutes. If it is not locked, verify this by repeating the step. If it is still not locked up, reboot and wait 12 minutes. Keep doing this process until you are sure that you know exactly how long it takes to lock up. If the time to lockup is determined to be a specific (dependable) amount, then the problem is with one of three settings: either the screen saver under DISPLAY properties in the Control Panel, the POWER MANAGEMENT properties in the Control panel, or the Power Management functions in your motherboard's CMOS Setup. To verify that the CMOS Setup is not the problem, boot the system with a floppy disk (so Windows does not load). Wait at least the specified amount, you determined above, of time and check the keyboard. If the keyboard still works, the problem is definitely in the software. If it's frozen, the CMOS is the problem. If you can't fix it in the CMOS, check with your dealer, because you may need a new motherboard. Good luck.