4 Replies Latest reply on Jan 27, 2011 8:10 AM by Michael L Hale

    Eraser mode?

    Ghoulfool Level 1

      I'm looking to write a script to simply cycle through the eraser modes (block, pencil & brush) and then bind the script to a keboard shortcut (old style). I've tried to see if you can just assign it a keyboard shortcut, but am unable. And I do realise that writing a script to do this is the long way round. However I can't seem to see anyting in the docs about eraser mode and it doesn't show up in the script listener. Can anyone help me out? Thank you.

        • 1. Re: Eraser mode?
          Paul Riggott Level 6

          You could create presets and switch them.

          • 2. Re: Eraser mode?
            Ghoulfool Level 1

            I could do but the negates the ability to simply cycle through them (which is only going to be the same keypress once or twice - no thinking or finding things in lists involved)

            • 3. Re: Eraser mode?
              Paul Riggott Level 6

              Er no, it means you only need one button, as an example....

              //cycle presets
              var cylclePrefs = new File("~/cyclePrefs.dat");
              var Index =0;
              if(cylclePrefs.exists){
                  cylclePrefs.open('r');
                  Index = Number(cylclePrefs.read());
                  cylclePrefs.close();
                  Index++;
                  if(Index>2) Index = 0;
                  }
              switch(Index){
                  case 0 : selectTool('cropTool'); selectToolPreset('Crop 4 inch x 6 inch 300 ppi'); break;
                  case 1 : selectTool('cropTool'); selectToolPreset('Crop 5 inch x 3 inch 300 ppi'); break;
                  case 2 : selectTool('cropTool'); selectToolPreset('Crop 8 inch x 10 inch 300 ppi'); break;
                  default : break;
                  }
              cylclePrefs.open('w');
              cylclePrefs.write(Index);
              cylclePrefs.close();
              function selectTool(tool) { 
                  var desc = new ActionDescriptor(); 
                      var ref = new ActionReference(); 
                      ref.putClass( app.stringIDToTypeID(tool) ); 
                  desc.putReference( app.charIDToTypeID('null'), ref ); 
                  executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO ); 
              };
              function selectToolPreset(TOOL) { 
                  var desc = new ActionDescriptor();
                      var ref = new ActionReference();
                      ref.putName( stringIDToTypeID('toolPreset'),TOOL );
                  desc.putReference( charIDToTypeID('null'), ref );
                  executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
              };
              
              • 4. Re: Eraser mode?
                Michael L Hale Level 5

                While I think Paul's script is good and the best that can be done now with a script, it is not ideal. Switching tool presets changes all the tool options.

                 

                A script can get the current tool options now. What is needed is to be able to set the options. That way a script could change just the mode without changing the other settings.