I was quite impressed with Rabbit's work on a previous thread so I thought that I would try my hand at developing some code to run x10 CM15A using SDK. It actually worked out quite well. I was not as fancy as Rabbit. He has the program read the setup from an Excel file. All my calls are hardwired (like "sendpcl" "b8 on" ) for my house, but Microsoft makes it quite easy with their MS Studio Express 2008 series of software programs. The x10 dll plugged right in, too.
In addition to turning lights on and off, I wanted to be able to view the video from the VA11a. I was able to find a bit of code for this on the web. Now I actually have something that works. I have attached an image of the user interface. I had no idea of how to paste an image into this post.
I am not a programmer so I am sure that there are lots of holes in the code, but it does work (please see below).
Option Strict Off
Option Explicit On
Imports ActiveHomeScriptLib
Friend Class Form1
Inherits System.Windows.Forms.Form
Dim WithEvents ActiveHomeObj As New ActiveHome
Const ws_visible As Integer = &H10000000
Const ws_child As Integer = &H40000000
Const WM_USER As Short = 1024
Const WM_CAP_EDIT_COPY As Integer = WM_USER + 30
Const wm_cap_driver_connect As Integer = WM_USER + 10
Const wm_cap_set_preview As Integer = WM_USER + 50
Const wm_cap_set_overlay As Integer = WM_USER + 51
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52
Const WM_CAP_SEQUENCE As Integer = WM_USER + 62
Const WM_CAP_SINGLE_FRAME_OPEN As Integer = WM_USER + 70
Const WM_CAP_SINGLE_FRAME_CLOSE As Integer = WM_USER + 71
Const WM_CAP_SINGLE_FRAME As Integer = WM_USER + 72
Const DRV_USER As Integer = &H4000
Const DVM_DIALOG As Decimal = DRV_USER + 100
Const PREVIEWRATE As Short = 30
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal a As String, ByVal b As Integer, ByVal c As Short, ByVal d As Short, ByVal e As Short, ByVal f As Short, ByVal g As Integer, ByVal h As Short) As Integer
Dim VideoSource As Integer
Dim hwndc As Integer
Dim hwndd As Integer
Dim saveflag As Short
Dim pictureindex As Short
Dim filter1(0 To 1, 0 To 1) As Single
Dim filter2(0 To 1, 0 To 1) As Single
Dim temp As String
Dim temp2 As String
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
Me.Close()
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
On Error GoTo handler
hwndc = capCreateCaptureWindow("CaptureWindow", ws_child Or ws_visible, 0, 0, VB6.PixelsToTwipsX(PichWnd.Width), VB6.PixelsToTwipsY(PichWnd.Height), PichWnd.Handle.ToInt32, 0)
If (hwndc <> 0) Then
temp = CStr(SendMessage(hwndc, wm_cap_driver_connect, 0, 0))
temp = CStr(SendMessage(hwndc, wm_cap_set_preview, 1, 0))
temp = CStr(SendMessage(hwndc, WM_CAP_SET_PREVIEWRATE, PREVIEWRATE, 0))
temp = CStr(SendMessage(Me.Handle.ToInt32, WM_CAP_EDIT_COPY, 1, 0))
Picture1.Image = My.Computer.Clipboard.GetImage()
Else
MsgBox("Unable to capture video.", MsgBoxStyle.Critical)
End If
Exit Sub
handler:
End
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "c1 on")
ActiveHomeObj.SendAction("sendplc", "c2 off")
ActiveHomeObj.SendAction("sendplc", "c3 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "c2 on")
ActiveHomeObj.SendAction("sendplc", "c1 off")
ActiveHomeObj.SendAction("sendplc", "c3 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "c3 on")
ActiveHomeObj.SendAction("sendplc", "c2 off")
ActiveHomeObj.SendAction("sendplc", "c3 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b2 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b2 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b3 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b3 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton11.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b4 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton10.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b4 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton13.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b6 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton12.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b6 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton15.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b8 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton14.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b8 off ")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b9 on")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Try
ActiveHomeObj.SendAction("sendplc", "b9 off")
Catch ex As Exception
'SendMessage(Err.Description, Err.Source, True, 0)
MsgBox("Error in using Sendplc!", MsgBoxStyle.Critical)
End Try
End Sub
'Button 1 capture clipboard that does work
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim test As New Bitmap
Clipboard.SetDataObject(PichWnd)
Picture1.Image = My.Computer.Clipboard.GetImage()
End Sub
End Class
[