Hi vishal812,
If as you mentioned you are able to spy the window then there should be no problem even if the size changes it should still highlight the window. Same with the button even if it changes position a button is detected properly anywhere on the screen if it is spyed correctly. Check the attributes and if there is something like window position or size then uncheck them.