AppleScript changing Input Source when Application is activated

Perhaps you can try “Set Keyboard Layout” action. It can be used to change input source. Change input source