You might be able to use Powershell.
Basic script that checks whether laptop is on AC or Battery and then modifies the power settings.
Reference the following links
https://www.powers-hell.com/2018/12/10/control-advanced-power-settings-with-powercfg-powershell/
https://devblogs.microsoft.com/scri...ettings-on-your-computer-by-using-powershell/
I have not tested or otherwise tried those links nor any other links that I found.
And I am not sure about the Powershell "logic" towards determining if a laptop is on AC or battery.
Knowing ("Get-") that information would be key to the necessary logic:
If "AC" then "High Performance" else "Balanced".
That said, if the laptop is in Battery mode and Balanced (as required) it seems to me that AC being in Balanced mode is moot. Charger not being plugged in.
Likely, overall more trouble than benefit.
Maybe set up a desktop shortcut that makes it easier for you to access and change the power setting when you need to do so.
Something like:
https://www.computerworld.com/article/3218116/how-to-make-shortcuts-to-windows-10-settings-on-your-desktop.html#:~:text=Here's how you can create custom Desktop icons,the shortcut a name, and click Finish.
Reference the Battery and power section.