4 Replies Latest reply on Aug 5, 2011 6:58 AM by Gregory Todd Smith

    Issues with manually adjusting a crop selection during a script.

    Gregory Todd Smith

      I've got a script that crops a template down to a specific area, but at the request of the user, that crop selection may need to be stretched to a larger area. So, I've got this code:

       

      var outsideInput = true;
      var cropArea = app.activeDocument.activeLayer.bounds;
      
      if(outsideInput){
           app.displayDialogs = DialogModes.ALL;
           app.activeDocument.crop(cropArea);
           app.displayDialogs = DialogModes.NO;
      }else{app.activeDocument.crop(cropArea)}
      

       

      Mind you this is an excerpt from a 1500 line script, so I changed the value of the input and there is a lot of context missing.

       

      At any rate, this code, run independently has no issues on the machine that is stuggling, but when it is run in the full script, when the script stops to allow the user to stretch the crop area, the crop box is unadjustable. Two machines out of five have this problem. The other three machines have the ability to adjust the box. I can find no setting that is different on the crop tool or in the application preferences that would disallow the user to stretch the crop selection.

       

      Is there any chance that this has to do with the DialogModes being set to ALL?

        • 1. Re: Issues with manually adjusting a crop selection during a script.
          Michael L Hale Level 5

          Are all machines running the same version of Photoshop?. I am not sure when it became possible to control user interaction with DOM methods using DialogModes. I never saw any code that did so until about a year ago and have not tested on older versions of Photoshop.

           

          Normally when I want to allow user interaction while the script is running I use scriptlistener code. I'll admit the DOM code for crop is shorter and easier to read but scriptlistener seems to work all the time.

          • 2. Re: Issues with manually adjusting a crop selection during a script.
            Gregory Todd Smith Level 1

            They're actually all brand new machines, so the OS version, hardware, software updates, and application versions are all the same. They're running Photoshop 5.1. This code has worked without fail on CS3 for the last two years, it works on CS5 on my machine, and CS5.5 on 4/6 of the new machines (I forgot about a sixth machine in another department).

             

            I had one of the two users whose machines is not allowing them to resize the crop area start up Photoshop with the ol' Ctrl+Alt + Shift to reset the preferences trick. Even after that and a restart, we had no luck.

            • 3. Re: Issues with manually adjusting a crop selection during a script.
              Paul Riggott Level 6

              I gave it a try with my windows 7 64bit / Photoshop CS5 (12.0.4) and the first time it didn't give the handles, but it did on subsequent tries.

              I tried with various rulerunit settings and all worked except having rulerunits set to percent it gave the wrong crop.

              • 4. Re: Issues with manually adjusting a crop selection during a script.
                Gregory Todd Smith Level 1

                Paul, I really appreciate your help and you looking into this for me. I tried the same things as you and I saw what you meant about setting the rulerunits to percent and the crop box not giving handles. The same was the case for me, on my machine. So, I tried it on one of the problem machines and realized - when they are running the same code that is functioning on all of the other PCs, the crop boxes have handles. You are just unable to click them. Anything you click on Photoshop just queues the infamous Windows *ding*.

                 

                The only options you have for ending Photoshop state of being frozen, awaiting interaction is to hit Enter (which crops to the unaltered selection) or to hit Escape (which will end the script and subsequently load the "Preferences > Units & Rulers" menu, which I find to be perplexing).