There are medications that can cause weight gain. But, those medications do that by increasing your appetite. I was on and off of Prednisone for over a decade. Prednisone is very well known for weight gain. I went from 195 pounds to 291 in about a year. I held that weight for a few years until I was told by literally one of the best weight loss doctors in the world that medications cannot defeat the "burn more calories than you take in" formula....period.
When I gained all that weight I was not eating processed food, or tons of processed sugar. I was eating what my body allowed, TONS of carbohydrates. Pasta, potatoes, rice, bread.....
Long story short....I took at least one 7.62x39 bullet to the lower abdomen while in Afghanistan in 2009.
It has been a long road back. Over 20 surgeries and many months in the hospital. (I have pictures but I dont want to get banned)

Part of my issue gaining weight besides the Prednisone was that a lot of my guts are gone. I do not process food like most others. The way my body processes food is to store a lot of fat. Thanks to great doctors everything works fine if you know what I mean.

Anyways, even with a body that constantly craves nutrition, I have lost over 80 of those pounds and am holding in the 210s...and still dropping. Eat less sugar, eat more protein and move a little and you WILL lose weight, even on medication. Luckily my lifestyle keeps me active.
Good luck on your journey, and use that CPAP machine. But seriously try to avoid too many medications. Just because a medication doesn't say it's physically addictive, it can become psychologically addicting.