Starting Corel Script Editor

If you want to create or edit a scripts, you can launch Corel Script Editor directly from the Tools menu. For more information about scripts and script syntax, see Corel SCRIPT online Help.

To start Corel SCRIPT Editor

• Click Tools, Corel SCRIPT, Corel SCRIPT Editor.

Corel SCRIPT application commands and functions

Any script you create by saving a recording of your CorelDRAW operations is comprised of Corel SCRIPT application commands. Corel SCRIPT application commands instruct CorelDRAW to perform specific actions. For example, a command might instruct CorelDRAW to open or to close a document. The application commands are easy to understand, since most are one-word equivalents of the corresponding Corel application user interface. For example, the .FileNew command creates a new document.

Although most CorelDRAW application commands are one-word equivalents of their corresponding menu commands, you might need more than the command itself to execute an action in these applications. If a command needs more information than is provided by the command name alone, parameters are required. Parameters represent aspects of the feature that you can change or selections you can make.

Application functions ask questions about the status of Corel applications, selected items in Corel applications, or image properties. For example, a function may ask CorelDRAW about an object's dimensions. Application functions are not recordable; they must be written into a script.

• Each Corel application that supports scripts has a unique set of application commands and functions. However, some Corel applications use the same name for a command or a function. For example, the .FileNew command is available in both CorelDRAW and Corel PHOTO-PAINT.

Corel SCRIPT programming statements and functions

Corel SCRIPT programming statements and functions are a common set of instructions that can be used with any Corel application that supports scripting. Programming statements and functions are derived from traditional BASIC programming language dialects. If you're already familiar with a version of BASIC, you'll find the Corel SCRIPT programming language easy to read and understand. If you've never programmed using BASIC, you'll be happy to know that BASIC is one of the easiest languages to read, understand, and learn.

Corel SCRIPT programming statements and functions send instructions or perform actions that aren't part of another Corel application. For example, Corel SCRIPT programming statements can be used to display a custom dialog box, include flow control statements and constructs such as loops, create and manipulate variables, and retrieve information about your computer setup. On their own, Corel SCRIPT programming statements form a powerful programming language. A script containing only Corel SCRIPT programming statements can be executed even if another Corel application is not running.

You can use a custom dialog box to get user input returned to a running script. Dialog boxes are created using Corel SCRIPT programming statements that support Windows options and controls such as push buttons, drop-down list boxes, option buttons, and progress indicators.

Using custom dialog boxes in scripts

You can create Corel SCRIPT statements used to produce a dialog box using two methods. The first method is to use Corel SCRIPT Editor and type in the dialog box definition statements. This can prove to be a time-consuming option, because each statement's parameters are specific and it is difficult to visualize the dialog box based on coordinate positions.

The second method is to use dialog windows in Corel SCRIPT Editor. In dialog windows, you draw what you want your dialog box to look like. The dialog box and the dialog box controls within it are graphical representations of Corel SCRIPT statements. Working with the dialog boxes in Corel SCRIPT Editor is similar to using a drawing or a painting application. In dialog windows, dialog box controls are graphic objects that can be inserted, moved, resized, and aligned in a dialog box. You can create or edit a dialog box in a few steps using Corel SCRIPT Editor.

Measurement units in CorelDRAW recordings and scripts

Most CorelDRAW scripting commands that use measurement parameters use tenths of a micron as the base unit of measurement. There are 10,000 such units in one millimeter, and one inch is made up of 254,000 tenths of a micron. For example, the two parameters of the .SetSize command specify new dimensions for the selected object in tenths of a micron.

Coordinates in CorelDRAW recordings and scripts

CorelDRAW scripting commands that specify locations on a page use coordinates as parameters. Coordinates use tenths of a micron as the base unit of measurement and are expressed as being relative to the center of the current page, which has the coordinates (0,0). For instance, the point (100000, 200000) would be located one centimeter left and two centimeters above the center of the page.

Most CorelDRAW commands that use coordinates, such as the .SetPosition command (sets the position of the selected object), are affected by the application's current reference point. This is the point on the selected object's bounding box that the coordinates operate on. For example, if the current reference point is set to 1 (meaning "top-left corner"), the .SetPosition 0, 0 command positions the selected object so that its top-left corner is at the center of the page. If the current reference point is set to 9 (meaning "center"), the .SetPosition 0,0 command has a different effect, positioning the current object so that its center is at the center of the page. You can set the current reference point with the .SetReferencePoint command. Since you cannot be sure what the current reference point is at the time your script starts, it is important that you call the .SetReferencePoint command before using any commands that take coordinate parameters. Otherwise, your script may not always behave predictably.

CorelDRAW script example

The following example creates a star shaped polygon with eight points and applies a custom conical fountain fill with three intermediate colors.

WITHOBJECT "CorelDraw.Automation.9"

.CreateSymPolygon 1032658, -862906, -693154, 877052, 8,1,1, TRUE,


.StoreColor 5002, 0, 0, 0,100, 0, 0, 0, 0 .StoreColor 5002, 0, 0, 0, 0, 0, 0, 0,100 .ApplyFountainFill 0, 0, 0, -3, 256, 0, 0, 50 .Undo

.ApplyOutline 0, 0, 0, 0, 0, 0, 0, 0, 0, FALSE, 0, 33810, FALSE


• Every script that contains CorelDRAW application commands must include a WITHOBJECT and END WITHOBJECT command.

OLE automation

OLE Automation is a flexible and powerful CorelDRAW feature that you can use to build applications that use CorelDRAW components.

OLE Automation is an integration standard that allows applications to expose their programmable objects so that other applications can control them. Exposing an object means that an application makes the script, or macro commands that control it, available to other programming applications. The exposed commands become an extension of the controlling programming language.

Any Corel application that supports Corel SCRIPT provides one programmable OLE automation object. The object is used by OLE automation controllers such as Corel SCRIPT to control Corel applications. You can also use OLE automation controllers such as Microsoft Visual Basic and Visual C++ to send commands to CorelDRAW and to develop applications using Corel application components.

OLE Automation can be used for long and complicated manual processes that transfer data between two or more applications. For example, you may have a manual process that puts data into a spreadsheet for creating a presentation graphic. The graphic is then used in a bitmap application such as Corel PHOTO-PAINT. If you use OLE Automation, you can create a program that automatically performs these steps for you. OLE Automation gives you almost total control over a variety of different applications, allowing you to build the applications you need through its seamless integration capabilities.

AutoScripts for CorelDRAW

AutoScripts are *.CSC or *.CSB files with special names that run in response to events within CorelDRAW. For example, if you want to insert your name or copyright information in the lower right corner of every document you print, you can write a script that inserts this information and save it as OnPrint.CSC. Every time the user sends a print job in CorelDRAW, this script will run before the print job is generated.

AutoScript Description

OnStart Runs after CorelDRAW is loaded, instead of any other startup features you may have selected. For instance, you can write a script to replace the Welcome to CorelDRAW dialog box that CorelDRAW displays by default.

OnOpen Runs after you open a new document.


Runs before you close a document. The script is responsible for calling

.FileClose (otherwise your document will stay open).


Runs every time you create a new document.


Runs when you start a print job but before the print job is actually sent

to the printer.


Runs when you exit CorelDRAW. After the script terminates, CorelDRAW


• AutoScripts must be placed in the Draw folder, not the Draw\Scripts folder.

• If you do not want an AutoScript to run, you can hold down SHIFT when the CorelDRAW event occurs. For instance, if you hold down SHIFT while CorelDRAW is starting, OnStart will not run.

• You may only run one script at a time. If a script is running and you attempt to trigger an AutoScript, the AutoScript will not run.

Was this article helpful?

0 0


  • carisio
    How to create coreldraw scripts?
    9 years ago

Post a comment