I would insert the codes near WinGet command, doesn't really matter as long as AHK execute it before you issue the ControlSend command. Preferably at the code region where you perform all the initialization.

Which AHK are you running? I am using the AHK_L 64 bits version.