Users of an in-house app I wrote sometimes complain of random crashes that we are unable to duplicate. I spent a few hours figuring out the COM interface for the Snagit screen shot and video capture tool and am posting it here so others can use it. Snagit comes with a 15 day free trial and costs $49 if you want a licensed copy. This code captures the window that calls the routine, but it can also be set to capture the whole screen or set portions of it.
Public Sub StartCapture()
if Running Then
EndCapture
app.SleepCurrentThread 500
end if
Running = True
VideoCapt = new SNAGITLib.VideoCapture
VideoCapt.MuteMic = True
VideoCapt.MuteSystemAudio = True
VideoCapt.ForegroundPreview = False
VideoCapt.EnablePreviewWindow = False
VideoCapt.OutputVideoFile.Directory = SpecialFolder.Documents.Child("SnagIt").NativePath
VideoCapt.OutputVideoFile.FileNamingMethod = SNAGITLib.snagOuputFileNamingMethod.sofnmAuto
VideoCapt.Input = SNAGITLib.snagVideoInput.sviWindow
VideoCapt.InputWindowOptions.SelectionMethod = SNAGITLib.snagWindowSelectionMethod.swsmActive
VideoCapt.IncludeCursor = True
VideoCapt.HideRecordingUI = True
VideoCapt.Start
TimeOutTimer.Period = TimeOut * 1000
TimeOutTimer.Mode = Timer.ModeSingle
End Sub
To stop the recording
Public Sub EndCapture()
TimeOutTimer.Mode = Timer.ModeOff
VideoCapt.Stop
Running = False
VideoCapt = nil
End Sub
Running is a boolean and the code stops the current instance before launching another one. Not doing this causes the MuteMic and MuteSystgemAudio routines to crash requiring a Windows restart before the routine will work again. The timer halts the video after a specified period. Installing Snagit will create the specified folder or you can put the files anywhere.