I think that there may be details missing from your description of your script.
At this time when I go to related record this opens a window for every item.
Go To Related Record only opens a single new window and only if you select that option.
however the script doesn't run in the "ItemPictureWindow"? What am I missing?
We'd need to see your script and a more detailed description of what you mean by "doesn't run". You can either post a screen shot of it from the scripts workspace, copy/paste the text from a PDF of a "print out" of your script, of you can use FileMaker Advanced to generate a DDR and copy/paste the script from there.
I will note that from your description, your Go To Related Records step is most likely changing your table occurrence context by specifying a layout based on an occurrence of the related table and that can affect whether the rest of your script does or does not work.
GTRR can't specify existing 2nd window as target.
There may be several ways, one is closing the 2nd window before GTRR if exists.