OVH Cloud OVH Cloud

Commander Télé par IR depuis PC

1 réponse
Avatar
smf-nft
Bonjour,

je tourne en rond depuis une semaine et j'ai besoin de votre aide.

je souhaite commander ma Télé/ ou autre (DVD/CD) depuis mon PC via un
programme en VB6. (voila le but du jeu :-) )

Mon problème est que je ne vois pas comment faire apprendre à mon PC les
codes de ma télé...

A priori je peux utiliser un port série pour bracher un module IR. Mais
ensuite, comment faire: 1/ pour trouver/voir les codes de mes télécommandes.
2/ faire sortir un signal (mais ça ça devrait être possible en utilisant
Mscomm32.ocx puis une commande .output = Mon code)

Quelqu'un pourrait-il me remonter le moral en me donnant une piste pour
résoudre mon problème ?

Merci bcp de votre aide.

Sébastien.

1 réponse

Avatar
François ROLAND
Voici un petit bout de code pour lire les code d'une telecommande IR en VB

c'est extremement brouillon, mais cela m'a permis par la suite de développer
une appli complete piloté par une telecommande IR





Dim txt$

Dim NewCode$





Sub exec_fonction()

'msg = MsgBox(txt$, 0, "")



If InStr(NewCode$, "254.42.13") Then MMC.Command = "play"
If InStr(NewCode$, "254.191.11") Then MMC.Command = "stop"
If InStr(NewCode$, "254.13.21") Then MMC.Command = "pause"
If InStr(NewCode$, "254.68.7") Then MMC.Command = "next"
If InStr(NewCode$, "254.136.14") Then MMC.Command = "prev"
If InStr(NewCode$, "254.39.24") Then MMC.Command = "eject"

If InStr(NewCode$, "254.133.27") Then
keybd_event 175, 0, 0, 0
keybd_event 175, 0, KEYEVENTF_KEYUP, 0
End If

If InStr(NewCode$, "254.89.15") Then
keybd_event 174, 0, 0, 0
keybd_event 174, 0, KEYEVENTF_KEYUP, 0
End If

If InStr(NewCode$, "254.181.60") Or InStr(NewCode$, "254.93.124")
Then
keybd_event 173, 0, 0, 0
keybd_event 173, 0, KEYEVENTF_KEYUP, 0
End If

If InStr(NewCode$, "254.32.58") Then Text2.Text = "0"
If InStr(NewCode$, "254.159.49") Then Text2.Text = "1"
If InStr(NewCode$, "254.61.50") Then Text2.Text = "2"
If InStr(NewCode$, "254.236.51") Then Text2.Text = "3"
If InStr(NewCode$, "254.168.52") Then Text2.Text = "4"
If InStr(NewCode$, "254.121.53") Then Text2.Text = "5"
If InStr(NewCode$, "254.219.54") Then Text2.Text = "6"
If InStr(NewCode$, "254.10.55") Then Text2.Text = "7"
If InStr(NewCode$, "254.83.56") Then Text2.Text = "8"
If InStr(NewCode$, "254.130.57") Then Text2.Text = "9"





If InStr(NewCode$, "254.45.47") Then b_quitter_Click
'If InStr(txt$, "þT") Then x = Shell("c:windowsnotepad.exe", 1)
'MSComm1.PortOpen = False: Unload Me


'keybd_event 175, 0, 0, 0
'keybd_event 175, 0, KEYEVENTF_KEYUP, 0



End Sub


Private Sub b_quitter_Click()

msg = MsgBox("bouton quitter", 0, "")


End 'Unload Me

End Sub

Private Sub Form_Load()



With MSComm1
.CommPort = 1 '.ComPort
.RThreshold = 1
.Settings = "1200,n,8,1"
.SThreshold = 1
.InputMode = comInputModeBinary

.PortOpen = True
.RTSEnable = True
.DTREnable = False
.RThreshold = 1
End With

MMC.FileName = "f:"
MMC.DeviceType = "CDAudio"
MMC.Command = "Open"




End Sub

Private Sub Form_Unload(Cancel As Integer)

MSComm1.PortOpen = False

End Sub

Private Sub MSComm1_OnComm()

Me.SetFocus


NewCode$ = ""
'Text1.Text = ""
Text1.Text = Text1.Text & "."

MSComm1.InputLen = 0


If MSComm1.InBufferCount Then

attente$ = attente$ & MSComm1.Input
txt$ = StrConv(attente$, vbUnicode)
'txt$ = attente$

End If



For i = 1 To Len(txt$)
NewCode$ = NewCode$ & Asc(Mid(txt$, i, 1)) & "."
'NewCode$ = NewCode$ & Mid(txt$, i, 1) & "."
Next i

If Len(NewCode$) <> 0 Then NewCode$ = Left$(NewCode$, Len(NewCode$) - 1)

Text1.Text = Text1.Text & NewCode$

exec_fonction


End Sub


"smf-nft" a écrit dans le message de
news:
Bonjour,

je tourne en rond depuis une semaine et j'ai besoin de votre aide.

je souhaite commander ma Télé/ ou autre (DVD/CD) depuis mon PC via un
programme en VB6. (voila le but du jeu :-) )

Mon problème est que je ne vois pas comment faire apprendre à mon PC les
codes de ma télé...

A priori je peux utiliser un port série pour bracher un module IR. Mais
ensuite, comment faire: 1/ pour trouver/voir les codes de mes


télécommandes.
2/ faire sortir un signal (mais ça ça devrait être possible en utilisant
Mscomm32.ocx puis une commande .output = Mon code)

Quelqu'un pourrait-il me remonter le moral en me donnant une piste pour
résoudre mon problème ?

Merci bcp de votre aide.

Sébastien.