Scripting

MaxIm DL provides an ActiveX Automation interface for scripting and externally controlling the camera and document processing operations. This interface is also used to support writing image processing plug-ins. Availability of this feature depends on Product Level.

Some simple sample scripts are included on the distribution disk. ActiveX is a platform-independent method for linking different applications together.

ActiveX can be accessed from just about any standard scripting or programming language, including VBScript, JScript, Java, Perl, Visual Basic, Visual C++, etc. Using ActiveX, you can even control MaxIm DL from Excel spreadsheet macros.

MaxIm DL is compliant with ASCOM scripting. This allows it to operate with a wide variety of astronomical software products such as planetarium programs, telescope control software, and dome control systems. Sample scripts are available for downloading from the ASCOM web page http://ascom-standards.org.

 

Scripting Languages

The most commonly-used scripting languages on the Windows platform are VBScript and JScript.

VBScript looks like a simplified version of Visual Basic (thus the name), but you do not require Visual Basic to create or run scripts. VBScript code is run by the Windows Scripting Host, which is included in Windows.

Similarly, JScript looks like Java code. JScript is run by the very same Windows Scripting Host that runs VBScript. Deciding which version to use is simply a matter of user preference.

VBScript and JScript allow you to write simple scripts using only the Notepad text editor, and run by double-clicking them in the Explorer or using MaxIm DL’s Run Script command.

Full documentation on the scripting languages is also available for download; please see Windows Scripting Reference,

 

Sample Scripts

In VBScript, you can take a picture as follows:

Dim cam ' "The" Camera object
Set cam = CreateObject("MaxIm.CCDCamera")
cam.LinkEnabled = True

if Not cam.LinkEnabled Then
   wscript.echo "Failed to start camera."
   Quit
End If

wscript.echo "Camera is ready, Exposing."

cam.Expose 1, 1, 0

Do While Not cam.ImageReady
Loop

cam.SaveImage "Script.fit"
wscript.echo "Exposure is done, Image saved as Script.fit"

If you want to try this, just copy the above code into a text file named "test.vbs". Double-click on the file to run it.

In Visual Basic you can access the MaxIm object the same way. However, another method is available which enables the Intellisense feature of Visual Basic: click References… under the Project menu. Scroll down to MaxIm and turn on the appropriate check box and click OK. You can then create a MaxIm camera object and take a picture as follows:

Dim Camera As New CCDCamera 'MaxIm camera object
Camera.LinkEnabled = True 'Start link to camera

If Not Camera.LinkEnabled Then
    MsgBox "Failed to start camera."
    End
End If

Camera.Expose 60, 1, 0 'Start a 60 sec exposure, shutter open, filter 0

Do While Not Camera.ImageReady
Loop

Camera.SaveImage "Script.fit"
MsgBox "Exposure is done, Image saved as Script.fit"

 

Tip: Use the Camera Simulator to test your scripts.