winlirc.gif (245 bytes) WinLIRC winlirc.gif (245 bytes)


Interfacing with Visual Basic

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


Copyright (C) 1999 Jim Paris <jim@jtan.com>.
Last update: Saturday, July 21, 2001 at 12:01 PM
Hits (since May 21,2001): [an error occurred while processing this directive]