Window focus on desk/page change?

Thanks, for having patience in finding a solution. For me a good exercise to learn and for other users a great function when we do find.

@somiaj: someone already setup functions using infostore to give the last active window focus.
I am sure someone made it. I was also browsing around.

Got another idea when I read @thomasadam Understanding Layers. Would it be possible to fix focused window to a layer and recall it on page return?