ReferenceError: Window does not have a constructor

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Andrew

ReferenceError: Window does not have a constructor

Post by Andrew »

This has got to the point of being seriously annoying. My main PC is off at the doctors for some surgey and I am forced to try working on my laptop.

My laptop has long had a strange bug. If I open Photoshop and run a script containing a dialog, it works fine first time. But the second time I run the exact same script, the script fails with:

ReferenceError: Window does not have a constructor

I have narrowed this down further. Even if the first script run does not have a dialog, no subsequent scripts will run successfully if they contain a window dialog (other than alert).

There is an awkward workaround. This behavious does not occur if I launch the script from Bridge.

I have tried reinstalling PS and all associated apps. Exactly the same.

And yet on my main PC when I use exactly the same installation process and source it works without problem.

Furthermore, the problem does not occur on my laptop with PS CS only CS2.

I have Googled the error message and it would seem no-one else has had this problem. Has anyone got any suggestions. I am not hopeful but I thought I would try asking.

Where it really becomes a nightmare is when I have some complex debugging to do and want to use the ESTK. The ESTK can only be used with CS2, so I have to close and restart PS with every iteration of my debugging process.

Andrew
johnbeardy

ReferenceError: Window does not have a constructor

Post by johnbeardy »

Hi Andrew

I've just started getting this same thing recently on my main PC, not on my laptop. The code is identical on each machine and both have CS2, only my main machine has some beta software installed (which you also have...) while the laptop does not. I share your findings especially about the script running fine first time. Sadly I don't have a solution and was at the Googling stage. Did you make any progress?

John
Andrew

ReferenceError: Window does not have a constructor

Post by Andrew »

No none, and this was happening long before I did any beta testing.

Andrew
johnbeardy

ReferenceError: Window does not have a constructor

Post by johnbeardy »

OK, well here it only occurred in the past few weeks and I should be find the last image updated by the script and perhaps work back to find possible changes to the system. If this helps pinpoint the error, I'll update you.

John
Andrew

ReferenceError: Window does not have a constructor

Post by Andrew »

To repeat something noted in the first post - there is a workaround. If you launch your Photoshop script from Bridge (I use my Bridge-Launch script to do this) then the problem does not occur.

Also, testing today, I found that I could launch the script multiple times from the ESTK and it worked. This is definitely new - previously the ESTK generated the same No Window Constructor error but now it seems not to.

As a matter of interest I do not have any beta testing software loaded on my laptop.

Andrew
johnbeardy

ReferenceError: Window does not have a constructor

Post by johnbeardy »

I may have made some progress. I tried clearing out the contents of the StartupScripts folder and restoring one script at a time, restarting Photoshop and testing. Any user-written scripts for Bridge caused the error message, even ones with no Window commands, neither a Window.alert nor a Show. But what worked was enclosing all the code after the target in a test for the BridgeTalk.app.Name.

So changing my Bridge scripts to test the BridgeTalk.appName appears to solve the issue. It doesn't answer why this suddenly became necessary on two machines at far ends of the world!

John
Trevor

ReferenceError: Window does not have a constructor

Post by Trevor »

I just ran into this as well. Thanks to the great investigative work done here, I was able to narrow it done to a single custom script in my StartupScripts folder. However, I'm still unclear what the "fix" is that's referenced here. That is, what is meant by "So changing my Bridge scripts to test the BridgeTalk.appName appears to solve the issue."? Thanks.
Trevor

ReferenceError: Window does not have a constructor

Post by Trevor »

Alright, I've tried adding:

if ( BridgeTalk.appName == "bridge" )

to the offending script, but no go. Guess I'll have to do some more digging...
Trevor

ReferenceError: Window does not have a constructor

Post by Trevor »

Nevermind. Got it working. It was nice talking to myself.