Hello and thank you for coming to Just Answer my name is Lachard.
First item I would check is the mouse or keyboard because sometimes it can be a defective or malfunctioning mouse or Keyboard.Unplug the mouse and keyboard while this is happening and see if it stops. If not it could be a device driver issue with your video let me know if the mouse fix does not work and I can look up the drivers for your pc.
We can try to upgrade the video drivers and see if this resolve the issue if it does not resolve it the issue is more than likely a loose video cable or the LCD has to be replaced. Let me know the model of your HP and I can track down the drivers for your laptop.
This is the correct website for the video driver you will just need to pick your operating system and version . Once you select this you can select graphic driver and if you have 32bit or 64bit. To find out if you have 32bit or 64bit you can go to start-right click computer and go to properties there it will show your version. Run the download please and reboot your computer and let me know if you are still having issues.