Just as the title says. I really have no idea how to translate the word "by" in this sense. It's just a form of grammar I've never even been exposed to, so I wouldn't know where to start. Anyone know how?
By pretending the dinner is real, Peter and his friends forgot about hunger. 通过假装晚餐是真的的方式， 潘和他的朋友们忘掉了饥饿。
Or you can take a little liberty:
I think I've found similar grammar that I do know how to use: 通过。 So I've just replaced all instances of this sort of "by" with "through." Seems to have identical meaning in English, so I'm fine with this.