Pivoting your thoughts from discouragement to hope can be as simple as using the word "maybe" more often in your self-talk.
If we're in the middle of something unpleasant, we can consciously skip to the place (emotionally) when we feel better. The way to do that is to use bridging thoughts that feel more hopeful than those you're currently thinking. Remember, they have to be things you believe, or they won't do you much good.
This blog Skullcoasting 101 is where I'll share everything I've learned so far. You will probably end up developing your own tips and tricks as you begin to try my suggestions. These aren't the answers, they're just a place to start. Once you begin, you'll be guided by your own voice from the inside out.