Hyundai Accent will not start after it has been driven

I have a 1998 Hyundai Accent that will not start after it has been driven for awhile and then sits for 15-30 minutes. Sometimes, it will start if you start it right back up after you turn it off, but if you wait, you are SOL. It usually starts back up after about 6-8 hours or overnight. I know it is an electical problem, because when it will not start, I have disconnected one of the spark plug wires and grounded it to the car, an get no spark. I have replaced the cam position sensor, throttle position sensor, and the ignition module, and I still have the same problem. I have put a code reader on the car and it reads no codes. Sometimes the check engine light is on after it has been sitting several hours after it would not start, and sometimes it is not. In either case it reads no codes. Is there anything else I can replace before I junk this car? Thanks

Look at the Crank Position Sensor also. In fact clean the connectors for the CmPS and the CkPS with contact cleaner that solved a similar problem with a 1996 Accent