It's a little tricky because if you move your mouse away from the active window, say try to run this from the script editor, your focus windows changes. But this does work if you make it a shelf button. Clicking in the viewport you want to make active, then clicking on this as a button will return your active camera. What are you planning to do with this? Just wondering if you need more code to select the camera, or what?
//Put this code on a shelf button to return the active camera name.
modelPanel -q -cam `getPanel -withFocus`;