See https://www.klayout.de/forum/discussion/1422/macro-development-window-no-save-as#latest for the original story.