Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting Photoshop CS2 61
In a script, you can access a
Document
object’s history states using the
HistoryStates
object, which is a
property of the
Document
object. You can use a
HistoryStates
object to reset a document to a previous
state or to fill a
Selection
object.
The following examples revert the document contained in the variable
docRef
back to the form and
properties it had when it was first saved. Using history states in this fashion gives you the ability to undo
modifications to the document.
AS
set current history state of current document to history state 1 ¬
of current document
VBS
docRef.ActiveHistoryState = docRef.HistoryStates(0)
JS
docRef.activeHistoryState = docRef.historyStates[0]
Note:
Reverting back to a previous history state does not remove any latter states from the history
collection. Use the
Purge
command to remove latter states from the
History States
collection as
shown below:
AS
purge history caches
VBS
appRef.Purge(2) 'for psPurgeTarget --> 2 (psHistoryCaches)
JS
app.purge(PurgeTarget.HISTORYCACHES)
The example below saves the current state, applies a filter, and then reverts back to the saved history state.
AS
set savedState to current history state of current document
filter current document using motion blur with options ¬
{angle:20, radius: 20}
set current history state of current document to savedState
VBS
Set savedState = docRef.ActiveHistoryState
docRef.ApplyMotionBlur 20, 20
docRef.ActiveHistoryState = savedState
JS
savedState = docRef.activeHistoryState
docRef.applyMotionBlur( 20, 20 )
docRef.activeHistoryState = savedState
Using Notifier Objects
You use the
Notifier
object to tie an event to a script. For example, if you would like Photoshop CS2 to
automatically create a new document when you open the application, you could tie a script that creates a
Document
object to an
Open Application
event.