The first thing that I would look at would be the properties of the object that TP can't find. Immediately after a failure, manually create an Object Map entry of the window or object that TP can't locate, but give it a name like "Aziz_window". Now in the object map, highlight the entry you just created and the one that's in the script and use the compare utility which will show you any properties that are different. Most likely one of those properties will be "significant" to TP and since they are not the same, TP can't find the object as defined in the Object Map. Once you know which property is changing you can deselect that property in the object map entry.
If the problem is not dynamic windows as smeagol is talking about... I have seen TP do something similar with menus where the window is not coming in focus before TP tries to do the menuselect. Since menus are disabled when out of focus, TP fails on the select.
You can try using the setfocus method after the attach. If that doesn't work... try using the Quickkey menu commands. Even if you don't drive the entire menu this way... just dropping the File menu down once before you start your pointer navigation will likely make the menus in focus and navigate-able.