Hi, thanks for reading.
At the moment im making an application to capture video from a webcam, and at the same time click various buttons that write to a text file to make notes on the video. I'v pretty much got everything down now apart from that the WM_CAP_SEQUENCE takes away control of the application by default during capture... so no button pressing. I need to pass in a capture parameters structure to tell it clicking is allowed, done through the bool yField being set to true. This is where i have a bit of trouble, im not used to structures and also not quite getting the grip of how to use WM_CAP_SET_SEQUENCE_SETUP, il post the relevant code below and hopefully someone might be able to offer me some insight or pointers?
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA", SetLastError = true)]
public static extern int SendMessage2(IntPtr webcam1, int Msg, IntPtr wParam, ref CAPTUREPARMS lParam);
CAPTUREPARMS CaptureParams = new CAPTUREPARMS();
CaptureParams.fYield = 1;
CaptureParams.fAbortLeftMouse = 0;
CaptureParams.fAbortRightMouse = 0;
CaptureParams.dwRequestMicroSecPerFrame = 66667;
CaptureParams.fMakeUserHitOKToCapture = 0;
CaptureParams.wPercentDropForError = 10;
CaptureParams.wChunkGranularity = 0;
CaptureParams.dwIndexSize = 0;
CaptureParams.wNumVideoRequested = 10;
CaptureParams.fCaptureAudio = 0;
CaptureParams.fLimitEnabled = 0;
CaptureParams.fMCIControl = 0;
CaptureParams.fStepMCIDevice = 0;
CaptureParams.dwMCIStartTime = 0;
CaptureParams.dwMCIStopTime = 0;
CaptureParams.fStepCaptureAt2x = 0;
CaptureParams.wStepCaptureAverageFrames = 5;
CaptureParams.dwAudioBufferSize = 0;
SendMessage2(webcam1, WM_CAP_SET_SEQUENCE_SETUP, new IntPtr(Marshal.SizeOf(CaptureParams)), ref CaptureParams);
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct CAPTUREPARMS
{
public System.UInt32 dwRequestMicroSecPerFrame;
public System.Int32 fMakeUserHitOKToCapture;
public System.UInt32 wPercentDropForError;
public System.Int32 fYield;
public System.UInt32 dwIndexSize;
public System.UInt32 wChunkGranularity;
public System.Int32 fCaptureAudio;
public System.UInt32 wNumVideoRequested;
public System.UInt32 wNumAudioRequested;
public System.Int32 fAbortLeftMouse;
public System.Int32 fAbortRightMouse;
public System.Int32 fMCIControl;
public System.Int32 fStepMCIDevice;
public System.UInt32 dwMCIStartTime;
public System.UInt32 dwMCIStopTime;
public System.Int32 fStepCaptureAt2x;
public System.UInt32 wStepCaptureAverageFrames;
public System.UInt32 dwAudioBufferSize;
public void SetParams(System.Int32 fYield, System.Int32 fAbortLeftMouse, System.Int32 fAbortRightMouse, System.UInt32 dwRequestMicroSecPerFrame, System.Int32 fMakeUserHitOKToCapture,
System.UInt32 wPercentDropForError, System.UInt32 dwIndexSize, System.UInt32 wChunkGranularity, System.UInt32 wNumVideoRequested, System.Int32 fCaptureAudio, System.Int32 fMCIControl,
System.Int32 fStepMCIDevice, System.UInt32 dwMCIStartTime, System.UInt32 dwMCIStopTime, System.Int32 fStepCaptureAt2x, System.UInt32 wStepCaptureAverageFrames, System.UInt32 dwAudioBufferSize)
{
this.dwRequestMicroSecPerFrame = dwRequestMicroSecPerFrame;
this.fMakeUserHitOKToCapture = fMakeUserHitOKToCapture;
this.fYield = fYield;
this.wPercentDropForError = wPercentDropForError;
this.dwIndexSize = dwIndexSize;
this.wChunkGranularity = wChunkGranularity;
this.wNumVideoRequested = wNumVideoRequested;
this.fCaptureAudio = fCaptureAudio;
this.fAbortLeftMouse = fAbortLeftMouse;
this.fAbortRightMouse = fAbortRightMouse;
this.fMCIControl = fMCIControl;
this.fStepMCIDevice = fStepMCIDevice;
this.dwMCIStartTime = dwMCIStartTime;
this.dwMCIStopTime = dwMCIStopTime;
this.fStepCaptureAt2x = fStepCaptureAt2x;
this.wStepCaptureAverageFrames = wStepCaptureAverageFrames;
this.dwAudioBufferSize = dwAudioBufferSize;