|This is a demonstration of how a script can be written that pauses
for the user to do
something that would otherwise be difficult or impossible to do from within the
script. This might include for example, aesthetic cropping, image
alignment, text attribute selection, etc.
One way to handle unscriptable user actions is to use multiple scripts. Run one script. Do whatever is not scriptable then run the second script. That is essentially what the Pause Script Demo does except it eliminates the need for multiple scripts. Basically what you are going to do is to record or write two (or more) scripts and then stitch them together so that all steps are in a single script. When you run the resultant script, it will do the first step and then exit. Running the script again will do the second step and so on until all the steps have been run.
Don't be scared away by all of the script stuff below. It's very easy to use. You just have to do a little bit of editing and almost all of it is cut and paste. The best way to explain it is look at an example and follow along with your own script. First we'll look at a very basic example of pausing and then we'll look at a more complicated example that shows some of the ways you can use the pause code in more detail.
Before we begin though, a few notes and caveats. The pause mechanism uses the currently open image to store the information needed to do the pause and to remember what's going on when the script is run subsequent times. Thus, pausable scripts must have an open image to run on. Also, the information is added to the image description so if you abandon a pausable script in the middle, you will leave some odd looking data there. To get rid of it, run the script again and when it asks you if you want to continue, say No and when it asks you if you want to stop all script steps, say Yes. Finally, if you are in the middle of a pausable script step and need to do something else, you can save the image in .pspimage format and come back to it later. The script information will be preserved and you can pick up where you left off.
Step 1: Start by recording two scripts that you want to use before and after the pause.
Step 2: Select the first script in the script list and press the Edit Selected Script button. Then press the Text Editor button.
The beginning of the script is pretty standard and won't change. It will look something like this:
Step 3: Add the next two lines after those above. These lines tell the pauser what the name of the script is. The script name is used to distinguish between this script and another pausable script that might be run while this one is paused. My script is going to be called Demo.
For this demo, I'm just going to use some very simple effects, namely Glowing Edges in step one and Kaleidoscope in step two. Your script steps can have as many effects in them as you want.
Step 4: Change the Do routine name to DoStep1. Note, case is important so make sure you use a capital S.
Step 5: Now we are going to add a message to the end of the script so that the user knows what to do when this script step ends.
Step 6: Select the second script and edit it. Copy the Do routine from the second script and paste it in after the routine above. Change its name from Do to DoStep2.
Step 7: Finally, we tack on the pause script code which makes the pausing possible. Download this code from the link below. Edit the Pause Script Demo script and copy the pause code from the start to the end markers and place it at the end of your script. The pause code will look like the following:
Save the script and run it. It will do the glowing edges and display the message. Click OK and then crop the image if you want to. Run the script again and it will do the kaleidoscope effect.
For reference, here is what the complete script should look like:
In the next section, we will look at the Pause Script Demo script itself. This script shows how to save data in one script step and use it in another. The script asks for some text in step one and uses it in step two.
Stay tuned for part two of this description...
Options to explore:
Download the script. Unzip it and place it in your Scripts-Restricted folder.
Open or create a new image. Select the Pause Script Demo script in the scripts list and press play. Enter some text and press return. Now switch to the Text Tool and select the font, size, etc. that you want. Press play to run the script again and it will continue with step two.
Changes in 0.1 (10/22/03):
Changes in 0.2 (11/18/03):
Changes in 0.3 (02/09/04):
Last modified 02/10/2004 09:03:19 AM