- Home
- Programming ZEMAX
- ZPL
- How to Automate Keyboard and Mouse Actions with ZPL
How to Automate Keyboard and Mouse Actions with ZPL
File Overview and Opening the ZPL dialog
Begin by opening the sample file, “Twyman-Green_2.ZMX,” which is available via download on the very last page of this article.
![]() | FILE: "Twyman-Green_2.ZMX" |
Note: This file is a slight modification of the Twyman-Green.ZMX sample file located in the ZEMAX>Samples>Non-Sequential>Ray Splitting directory.
As the file currently exists, the TEST SURFACE (Object 4) is perfectly aligned, and the resulting fringes on the screen are exclusively indicative of spherical aberration. In this demonstration, we would like to see how the interference fringes at the detector screen change as we slightly tilt the test surface. We may automate the process by constructing a straightforward macro in ZEMAX.

Macros can be created/edited using any ASCII text editor (such as the NOTEPAD editor). Sometimes, it is probably easiest to start with an existing macro that performs a task similar to the one you want to achieve. That way, you may simply make the necessary modifications to the existing macro and save it under a different file name, without having to write the entire macro from scratch.
In cases such as these, you may select “Macros > Edit/Run ZPL macros…” from the ZEMAX main menu or press F9 on your keyboard. Upon doing so, the ZEMAX Programming Language dialog will appear, which includes the entire list of current macros in your ZEMAX > Macros directory. You may choose an existing macro and execute it, or you may choose to edit the file via the “Edit” button:

Selecting “Edit” will open the selected macro in the NOTEPAD Editor. You may then edit the desired text, or you may delete the entire macro and start with a blank screen.
For the current demonstration, we will start with a completely blank text editor. Note that EditPlus 2 is the text editor software which will be used in the following pages of this article.

