Martin Kubik writes:
If you will be asked this question again --> here is the answer how to do. Maybe it's not the best solution but it works:
Include the Microsoft Winsock Control 5.0 Componente an Create an Object like Winsock1. Open connection to the WinLircServer like in the Form_Load() Procedure. Since now, the open was O.K, you can receive messages with the Winsock1_DataArrival() Procedure. Everytime WinLirc recognices a remote key it will be send to all connected (max. 6) programms. In this case the Winsock1_DataArrival() will be called if data is received from WinLirc.
Private Sub Form_Load() Dim strLocalIP As String strLocalIP = Winsock1.LocalIP Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = strLocalIP Winsock1.RemotePort = 8765 Winsock1.Connect End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim strData As String Dim strRemoteHex, strRemoteName, strRemoteKey As String Dim intRemoteIdx, intSeperatorOne, intSeperatorTwo As Integer Winsock1.GetData strData, vbString Text1.Text = strData 'Messagestring from WinLirc strRemoteHex = Left(strData, 16) intRemoteIdx = Val(Mid$(strData, 18, 2)) intSeperatorOne = InStr(21, strData, " ", vbBinaryCompare) strRemoteKey = Mid$(strData, 21, intSeperatorOne - 21) 'Code of the Key from Remote Control intSeperatorTwo = InStr(intSeperatorOne, strData, Chr(10), vbBinaryCompare) strRemoteName = Mid$(strData, intSeperatorOne + 1, (intSeperatorTwo - intSeperatorOne) - 1) 'Name of the Key - defined in WinLircServer Text2.Text = "KEY:" & strRemoteKey & " Control:" & strRemoteName End Sub
Sending commands should be as simple as:Dim sendstr As String Dim password, remotename, buttonname As String sendstr = (password & " " & remotename & " " & buttonname & " " & times_to_repeat & vbLf) Winsock1.SendData (sendstr)
times_to_repeat is an optional parameter the default value is "0"
Copyright (C) 1999 Jim Paris <jim@jtan.com>.
Last update: Thursday, June 13, 2013 at 08:27 PM
Hits (since May 21,2001):