Maxim dl Autofocus Script Help

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

  1. WW Ron

    WW Ron Cyanogen Customer

    Joined:
    Nov 8, 2016
    Messages:
    5
    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."
    Quit
    End If

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

    wscript.echo "Autofocus routine started."
    af.AutoFocus()
    Do While Not AutoFocusStatus
    WScript.Sleep 1000
    Loop

    upload_2019-8-14_15-48-52.png
     
    Last edited: Aug 14, 2019
  2. WW Ron

    WW Ron Cyanogen Customer

    Joined:
    Nov 8, 2016
    Messages:
    5
    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 )
    PrepareToImage
    If Error <> "" Then Exit Sub

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

    Do
    wscript.Sleep 100
    Loop While App.AutofocusStatus < 0

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

Share This Page