Won't work. You have to have a mechanical, physical way to change the connection path. I used to do this with a switch made for that purpose.
The older ones, used but working go for under $20.
The new ones cost more that getting non old monitor from a local thrift store.
EDIT: Yeah, there is another way,n but I sensed that you were cost restrained. Commercial and industrial users have a special method with auto-switching devices. If you shave to ask what it cost, you can't afford it.