Maxim dl Autofocus Script Help

Discussion in 'Scripting and Programming' started by WW Ron, Aug 14, 2019.

  1. WW Ron

    WW Ron Cyanogen Customer

    Nov 8, 2016
    I've been looking for a script to run in Autosave to kick off the Maxim dl Autofocus routine. I have "0" scripting knowledge. I found the below script on the internet and it runs the routine after my test image and does focus, but it hangs and never give up control until I close the command window manually. The next image then start normally and continues. Any help or if someone has a another script it would be a great help.

    'Refocusing Script V1.0 for MaximDL imaging (autosave) sequences
    Dim cam
    Set cam = CreateObject("MaxIm.CCDCamera")
    Dim af
    Set af = CreateObject("MaxIm.Application")
    cam.LinkEnabled = True
    if Not cam.LinkEnabled Then
    wscript.echo "Failed to start camera."
    End If

    af.FocuserConnected = True
    if Not af.FocuserConnected Then
    wscript.echo "Failed to connect the focuser."
    End If

    wscript.echo "Autofocus routine started."
    Do While Not AutoFocusStatus
    WScript.Sleep 1000

    Last edited: Aug 14, 2019
  2. WW Ron

    WW Ron Cyanogen Customer

    Nov 8, 2016
    In my searching around I came across sample scripts on the MaxIm DL Extras page. In the Sequenced Image Acquisition script there is a section to perform an Autofocus. I thought that I had found just what I was looking for. I copied the part I thought was needed but I must be missing something because it won't execute. Anyone ever try this before or see something I could be missing?

    ' perform an autofocus sequence and wait for it to complete
    Sub AutoFocus( Duration )
    If Error <> "" Then Exit Sub

    Dim App
    Set App = CreateObject( "MaxIm.Application" )
    App.AutoFocus Duration

    wscript.Sleep 100
    Loop While App.AutofocusStatus < 0

    If App.AutofocusStatus = 0 Then Error = "Autofocus failed"
    End Sub

Share This Page