getting nowhere fast

any suggestions anyone?
(p.s the reason for wanting this to accurately set the name of the window is that I was trying to add a simple function to restore minimised app versions when the app is relaunched. something that is usually done with window names without any problems - hence finding that the window names were not working correctly)