the crux of my solution is that the mainwindow title doesn't change, if you activate a viewport.
mainwindow title contains sheet-title, string uiViewTitle contains activeView-title.
I tested with Revit 2017 - macro, I'll do some more testing with Revit 2018 - ExternalCommand