"are you sure you want to shutdown your computer?" random popups

I have a mid 2010 MacBook Pro. when inactive for 5 seconds it pops up a message saying "are you sure you want to shutdown your computer now? It does this by itself like clockwork and if I don't press cancel immediately it shuts down. I have jammed one of the keys down so its not inactive and this has stopped the pop ups but that is obviously not the right thing to do, please help!

Hi Dan thanks for the assistance, not me personally but I did buy it second hand so there is that possibility, however I haven't noticed any problems with the keyboard or trackpad they both seem to work perfectly, how would I be able to tell if there has been a liquid spill?

If you do lets open up the system and do an inspection to see how it looks. Post pictures of anything that looks suspect. Dust it out using a soft brush and can'ed air.

What we'll want to do here is disconnect the keyboard and trackpad ribbon connections then using the USB keyboard & mouse see if you still encounter the problem. I'll warn you the system will ramp up the fans as they are going into Safe mode as the sensor or the trackpad will be disconnected when you pull its connection so don't let that bother you. We don't want to let it stay this way too long either as you don't want to over stress the fans.

Follow this IFIXIT guide: MacBook Pro 13" Unibody Mid 2010 Upper Case Replacement Follow the first three steps, then jump down to Step 11 pulling the trackpad connection (3rd image) and follow Step 12. Use care as you don't want to damage the connector or the ribbon cable. To ease it back in I use a small piece of electricians black tape folded over to make a pull stuck on the ribbon.

Is the system still wanting to shut down? If not you'll need a new keyboard. If is still wants to shutdown we'll need to look into the battery & temperature sensors within the system.

Resources

Repairability

Stay in the loop

It's time to speak out for your right to repair

We have a chance to guarantee our right to repair electronic
equipment—like smartphones, computers, and even farm equipment. This is a once-in-a-generation
chance to protect local repair jobs—the corner mom-and-pop repair shops that
keep getting squeezed out by manufacturers.

Join the cause and tell your state representative to support Right to Repair. Tell them you believe repair should be fair, affordable, and accessible. Stand up for your right to repair!