Just a note that it's possible (though unlikely) that the parameters passed to ActivateWindow et. al. may not be escaped or quoted. Further, the window in ActivateWindow() might be a translated window already.

A safer bet would be to parse the parameter using the builtins parser and set it up based on that - that handles all the escaping of params etc.