On Select - Go to Previous Modifier-Subobject?

Does anyone know of, or can you help with the following script:

- On selecting an object it selects the same modifier and sub-object that was selected before you deselected the object.

ie. You're working on Object A in Edge mode of an Edit Poly modifier. You select a different object. You then reselect Object A and it instantly returns to Edge mode of the Edit Poly modifier.