I’ve created a small tool to handle that. It is not complete but I’m receiving positive feedback and still working on it.
It is free, you have source code (C++), you may compile it with Cygwin and there are binaries if you don’t compile C++ code.
You may find it here: https://github.com/manutalcual/winredock
Are you expecting to be able to go from two external displays, one internal display, then back to two external displays, and restore the windows positions? If so, you’ll need to use a third-party utility to save window positions and restore them.
WinSize2 should do what you want. Others have mentioned AutoHotKey scripts and AutoIT as well.
This answer mentions AutoResizer, which is a huge step forward in helping me maintain sanity: Windows utility to save/restore window size & position history?
How to stop windows resizing when the monitor display channel is turned off / switched to different source
I recommend PersistentWindows which just works also very convenient on RDP sessions with different resolutions remote desktop connection.