I figured it out. I went to Control Panel\Clock, Language, and Region\Language\Advanced settings, and under switching input methods, I clicked on Let me set a different input method for each app window. Things are much better now.
How come I could not figure this out after months of trying, but as soon as I posted this question, I solved it in less than 15 minutes?