Are you sure you aren't depressed? That can definitely affect motivation.
Loneliness can be resolved when you meet some people you truly like and relate to. Are you trying by doing things such as joining clubs, getting out and doing fun things, etc.?
As far as getting work done, I would think about the future and what doing a good job would get me later on. Plus I truly was motivated by trying to get good grades for the sake of patting myself on the back. Some courses I really didn't enjoy at all, but I saw them as a challenge.
If you feel really down, then I suggest you check into talking to a school counselor. I am concerned about the self-injury thoughts. Okay?