What should one do if he mistakenly davens (e.g. Mincha) a second time, and remembers half way through Shemoneh Esrei?
On your twist: If you realized in the middle and it is an acceptable time to daven maariv, it seems from the Shaarei Tshuva siman 422 that you can have kavana that this tfilah be for maariv and you would be yotzei maariv.
The case in the shaarei tshuva is if one begins to daven mussaf on rosh chodesh, and realizes after the first three brachos that he has not davened shacharis, he should use this tfilah to daven shacharis and then daven mussaf afterwards. From here it seems one could substitute one tfilas chovah for another, even though it is clear from the mishanh brurah in the other answer to this question that you can't substitute a nedavah for a chovah.