The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Clearing the Adobe ExtendScript ToolKit Console Window

TODO: Pull subtitle into page object

A screenshot of the ExtendScript Toolkit text editor and JavaScript Console windows

By default, this window doesn't clear itself before each run which degrades a lot of its value. It can be cleared manually before the start of each test run, but that's a pain.

The good news is there's a way to do it with code. If the script is run from ExtendScript Toolkit itself, this snippet of code will do it:

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Clearing the Adobe ExtendScript ToolKit Console Window

While creating a new JavaScript to automate some 
day-job Photoshop work, I gave Adobe's ExtendScript Toolkit 
a spin. It's designed specifically for building 
scripts for Adobe products and it's pretty nice. 
Especially the JavaScript Console window that makes 
it nice and easy to see debugging messages.

-- image
-- awsgrab-20140227--1524-01a

A screenshot of the ExtendScript Toolkit text editor and JavaScript Console windows

-- p

By default, this window doesn't clear itself before 
each run which degrades a lot of its value. It can be 
cleared manually before the start of each test run, 
but that's a pain. 

The good news is there's a way to do it with code. If the 
script is run from ExtendScript Toolkit itself, this snippet 
of code will do it:

-- code/
-- javascript

app.clc();

-- /code


Unfortunately, that same code causes Photoshop to 
choke which defeats the purpose. The first solution I came 
up with to get around this is to check to make sure the 
script was being run in ExtendScript ToolKit before making the call.

-- code/
-- javascript

if (app.name === "ExtendScript Toolkit") { 
  app.clc(); 
}

-- /code


This clears the console when run in ExtendScript 
ToolKit but not Photoshop. Useful for early 
stage development but resulting in having to fall 
back to manually clearing after each Photoshop run. 

After some digging through the "Interapplication 
Communication with Scripts" chapter of the 
"JavaScript Tools Guide CS6" docs, I came up with this:

-- code/
-- javascript

if (app.name === "ExtendScript Toolkit") { 
  app.clc(); 
}
else {
  var estApp= BridgeTalk.getSpecifier("estoolkit");
  if(estApp) {
    var bt = new BridgeTalk;
    bt.target = estApp;
    bt.body = "app.clc()";
    bt.send();
  }
}

-- /code

This code checks to see if the script is being run 
from ExtendScript Toolkit. If so, it clears the console 
natively. If the script is being run in another app 
(e.g. Photoshop), it attempts to send the clear message 
to ExtendScript Toolkit.

An alternate way to clear the console would be to 
use the `Cmd+Shift+C`` hot-key combo, but I'd much 
rather let the script do it for me.

-- categories
-- Miscellaneous

-- metadata
-- date: 2014-02-27 00:00:00
-- id: 20emxndx
-- status: published
-- type: archive
-- site: aws