Accueil > > > DLL UTILISANT LE MODEM POUR APPELER UN NUMÉRO DE TEL
DLL UTILISANT LE MODEM POUR APPELER UN NUMÉRO DE TEL
Information sur la source
Description
Ce début de dll permet d'appeler et de raccrocher le tel via le modem, il utilise le composant Mscomm de VB. Mode opératoire pour utiliser ClPhone.dll Tout d'abord, il faut référencer la dll dans le projet. Puis il faut créer une variable permettant de d'instancier l'objet ClPhone Liste des propriétés oPbStandard : Propriété qui permet de renseigner si la ligne se trouve derrière un standard. Dans ce cas là, on rajoutera 0 devant le numéro de téléphone. oPsPortSetting : Propriété concernant la configuration du port série (Vitesse, Bits de parité,Bit de Données Valide, valeur d'arrêt) oPiPortNumber : Propriété concernant le numéro du port (Ex : 1 = COM1 , 2 = COM2 etc..) oPsPhoneNumber : Propriété qui concerne le numéro de téléphone qu'on veut appeler. (Ex: 0328333543) oPbHangDown : Propriété qui permet de raccrocher et de terminer l'appel. Méthode pour faire un appel : RbCallNumber : Méthode qui permet de faire un appel selon les propriété que l'on définira au préalable. Pour raccrocher, il suffira de mettre la propriété oPbHangDownà vrai.
Source
- Option Explicit
-
- Dim sOpsPortSetting As String 'Propriété du Port
- Dim sOpsPhoneNumber As String 'Numéro de téléphone à appeler
- Dim bOpbStandard As Boolean 'Flag pour savoir si la ligne est derrière un standard
- Dim boPbHangDown As Boolean 'Flag qui raccroche le tel
- Dim iOpiPortNumber As Integer 'Numéro du port
- Dim oCom As MSComm 'Objet de communication Port
- Dim WithEvents oVoice As SpVoice
-
-
- 'Propriété qui Rend la fenêtre de conncetion visible ou non
- Public Property Let oPbVisible(bVisible As Boolean)
- Frm_TestModem.Visible = bVisible
- If bVisible Then
- Frm_TestModem.WindowState = vbNormal
- End If
- End Property
-
- Public Property Get oPbVisible() As Boolean
- oPbVisible = Frm_TestModem.Visible
- End Property
-
- 'Propriété qui renseigne si la ligne se trouve derrière un standard ou non
- Public Property Let oPbStandard(bStandard As Boolean)
- bOpbStandard = bStandard
- End Property
-
- Public Property Get oPbStandard() As Boolean
- oPbStandard = bOpbStandard
- End Property
-
- 'Propriété qui fais racrocher le telephone
- Public Property Let oPbHangDown(bHangDown As Boolean)
- boPbHangDown = bHangDown
- 'If bHangDown And oCom.PortOpen Then oCom.PortOpen = False
- End Property
-
- Public Property Get oPbHangDown() As Boolean
- oPbHangDown = boPbHangDown
- End Property
-
-
- 'Propriété de configuration du port
- Public Property Let oPsPortSetting(strPortSetting As String)
- sOpsPortSetting = strPortSetting
- End Property
-
- Public Property Get oPsPortSetting() As String
- oPsPortSetting = sOpsPortSetting
- End Property
-
- 'Propriété qui définit le numéro de telephone à appeler
- Public Property Let oPsPhoneNumber(strPhoneNumber As String)
- If oPbStandard Then
- sOpsPhoneNumber = "0" & strPhoneNumber
- Else
- sOpsPhoneNumber = strPhoneNumber
- End If
- End Property
-
- Public Property Get oPsPhoneNumber() As String
- oPsPhoneNumber = sOpsPhoneNumber
- End Property
-
- 'Propriété qui définit le numéro du port série
- Public Property Let oPiPortNumber(iPortNumber As Integer)
- If iPortNumber = 0 Then
- iOpiPortNumber = 1
- Else
- iOpiPortNumber = iPortNumber
- End If
- End Property
-
- Public Property Get oPiPortNumber() As Integer
- If oPiPortNumber = 0 Then
- oPiPortNumber = 1
- Else
- oPiPortNumber = iOpiPortNumber
- End If
- End Property
-
- Public Property Let oPlColorError(oColorError As OLE_COLOR)
- oColor_Bad = CLng(oColorError)
- End Property
-
- Public Property Get oPlColorError() As OLE_COLOR
- oPlColorError = oColor_Bad
- End Property
-
- Public Property Let oPlColorSucceed(oColorSucceed As OLE_COLOR)
- oColor_Good = CLng(oColorSucceed)
- End Property
-
- Public Property Get oPlColorSucceed() As OLE_COLOR
- oPlColorSucceed = oColor_Good
- End Property
-
-
- Public Function RbCallNumber() As Boolean
- Dim st As String
- Dim Cde As String
- Dim boPbHangDown As Boolean
- Dim modem As String
- Dim oCom1 As Object
-
- Frm_TestModem.Visible = False
-
- ' Définition des paramètres du port
- Set oCom = Frm_TestModem.MSComm1
- If Not oCom.PortOpen Then
- oCom.CommPort = iOpiPortNumber 'Numéro du port série
- oCom.Settings = sOpsPortSetting '"300,N,8,1"
- End If
-
- ' Ouverture du port
- On Error Resume Next
- oCom.PortOpen = True
-
- If Err Then
- st = "COM" + Str(oCom.CommPort) + " n'est pas disponible. "
- st = st + "Utilisez le menu Port pour sélectionner un autre port de communication."
- MsgBox st
- RbCallNumber = False
- End If
-
- ' Purge du tampon d'entrée
- oCom.InBufferCount = 0
-
- ' Composition du numéro
- Cde = "ATDT " + sOpsPhoneNumber + ";" + Chr$(13)
- oCom.Output = Cde
-
- ' Attente de la chaîne boPbHangDown en provenance du modem
- boPbHangDown = False
- Do
- ' Si il y a des données dans la tampon, les lit.
- If oCom.InBufferCount Then
- DoEvents
- modem = modem + oCom.Input
- ' If InStr(modem, "OK") <> 0 Then
- ' MsgBox "Décrochez le téléphone et appuyez sur le bouton Ok."
- ' DoEvents
- ' 'oPbHangDown = True
- ' End If
- End If
- DoEvents
- Loop Until oPbHangDown
-
- ' Déconnection du modem
- oCom.Output = "ATH" + Chr$(13)
-
- ' Fermeture du port
- oCom.PortOpen = False
- End Function
-
- Private Sub Class_Initialize()
- oColor_Good = &H0
- oColor_Bad = &H808080
- bOpbStandard = True
- sOpsPortSetting = "300,N,8,1"
- sOpsPhoneNumber = ""
- iOpiPortNumber = 1
- Set oVoice = New SpVoice
- End Sub
-
-
- Private Sub Class_Terminate()
- On Error Resume Next
- ' Fermeture du port
- oCom.PortOpen = False
- Set oVoice = Nothing
- Set oCom = Nothing
-
- End Sub
-
-
- '*** Méthode
- ' ***********************************************************
- ' FONCTION: DialNumber()
- '
- ' Explication : Composer un numéro de tel en utilisant le modem du PC
- '
- ' Paramètre:
- ' PhoneNumber: Numéro de tel à composer
- '
- ' ***********************************************************
- Public Function DialNumber(PhoneNumber)
- Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
- Dim RetVal As Long
-
- ' Demande à l'utilisateur de décrocher le téléphone.
- Msg = "SVP, décrocher le combiner et cliquer OK pour composer le numéro " _
- & PhoneNumber
- MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
- MsgBoxTitle = "Numéro de Tel"
-
- If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
- Exit Function
- End If
-
- ' Envoyer le numéro de tel par modem.
- RetVal = tapiRequestMakeCall(PhoneNumber, "Phone", "", "")
-
- If RetVal < 0 Then
- Msg = "Impossible de composer le numéro " & PhoneNumber
- GoTo Err_DialNumber
- End If
-
- Exit Function
-
- Err_DialNumber:
- Msg = Msg & vbCr & vbCr & _
- "Vérifiez que le Port série n'est pas utilisé par un autre utilisateur"
- MsgBoxType = MB_ICONSTOP
- MsgBoxTitle = "Erreur lors de la composition du numéro"
- MsgBox Msg, MsgBoxType, MsgBoxTitle
-
- End Function
-
- Public Sub sbTextToSpeech(strMessage As String)
- On Error GoTo ErrSpeech
- 'Declarations
- '
- ''Code:
- 'oVoice.Speak strMessage, SVSFlagsAsync
- '
- ''This will speak to default out put audio device (speaker)
- ''In case you want to direct the speech to telephone
- ''Add a MSCom control to your project
- ''Dial a telephone number
- ''Once picked up on other side [You need to know AT commands]
- ''set the oVoice output to telephone object and play the stream
- '
- oVoice.AllowAudioOutputFormatChangesOnNextSet = False
- oVoice.AudioOutputStream.Format.Type = 6
- Set oVoice.AudioOutputStream = oVoice.AudioOutputStream
- Set oVoice.Voice = oVoice.GetVoices().Item(0)
-
- Set oVoice.AudioOutput = oVoice.GetAudioOutputs().Item(1) '"Your telephone object"
- Debug.Print oVoice.AudioOutput.GetDescription
-
-
- oVoice.Speak strMessage, SVSFlagsAsync Or SVSFPurgeBeforeSpeak Or SVSFIsXML ' SVSFDefault ' Flags
- Exit Sub
- ErrSpeech:
- MsgBox Err.Description
- End Sub
-
-
-
-
Option Explicit
Dim sOpsPortSetting As String 'Propriété du Port
Dim sOpsPhoneNumber As String 'Numéro de téléphone à appeler
Dim bOpbStandard As Boolean 'Flag pour savoir si la ligne est derrière un standard
Dim boPbHangDown As Boolean 'Flag qui raccroche le tel
Dim iOpiPortNumber As Integer 'Numéro du port
Dim oCom As MSComm 'Objet de communication Port
Dim WithEvents oVoice As SpVoice
'Propriété qui Rend la fenêtre de conncetion visible ou non
Public Property Let oPbVisible(bVisible As Boolean)
Frm_TestModem.Visible = bVisible
If bVisible Then
Frm_TestModem.WindowState = vbNormal
End If
End Property
Public Property Get oPbVisible() As Boolean
oPbVisible = Frm_TestModem.Visible
End Property
'Propriété qui renseigne si la ligne se trouve derrière un standard ou non
Public Property Let oPbStandard(bStandard As Boolean)
bOpbStandard = bStandard
End Property
Public Property Get oPbStandard() As Boolean
oPbStandard = bOpbStandard
End Property
'Propriété qui fais racrocher le telephone
Public Property Let oPbHangDown(bHangDown As Boolean)
boPbHangDown = bHangDown
'If bHangDown And oCom.PortOpen Then oCom.PortOpen = False
End Property
Public Property Get oPbHangDown() As Boolean
oPbHangDown = boPbHangDown
End Property
'Propriété de configuration du port
Public Property Let oPsPortSetting(strPortSetting As String)
sOpsPortSetting = strPortSetting
End Property
Public Property Get oPsPortSetting() As String
oPsPortSetting = sOpsPortSetting
End Property
'Propriété qui définit le numéro de telephone à appeler
Public Property Let oPsPhoneNumber(strPhoneNumber As String)
If oPbStandard Then
sOpsPhoneNumber = "0" & strPhoneNumber
Else
sOpsPhoneNumber = strPhoneNumber
End If
End Property
Public Property Get oPsPhoneNumber() As String
oPsPhoneNumber = sOpsPhoneNumber
End Property
'Propriété qui définit le numéro du port série
Public Property Let oPiPortNumber(iPortNumber As Integer)
If iPortNumber = 0 Then
iOpiPortNumber = 1
Else
iOpiPortNumber = iPortNumber
End If
End Property
Public Property Get oPiPortNumber() As Integer
If oPiPortNumber = 0 Then
oPiPortNumber = 1
Else
oPiPortNumber = iOpiPortNumber
End If
End Property
Public Property Let oPlColorError(oColorError As OLE_COLOR)
oColor_Bad = CLng(oColorError)
End Property
Public Property Get oPlColorError() As OLE_COLOR
oPlColorError = oColor_Bad
End Property
Public Property Let oPlColorSucceed(oColorSucceed As OLE_COLOR)
oColor_Good = CLng(oColorSucceed)
End Property
Public Property Get oPlColorSucceed() As OLE_COLOR
oPlColorSucceed = oColor_Good
End Property
Public Function RbCallNumber() As Boolean
Dim st As String
Dim Cde As String
Dim boPbHangDown As Boolean
Dim modem As String
Dim oCom1 As Object
Frm_TestModem.Visible = False
' Définition des paramètres du port
Set oCom = Frm_TestModem.MSComm1
If Not oCom.PortOpen Then
oCom.CommPort = iOpiPortNumber 'Numéro du port série
oCom.Settings = sOpsPortSetting '"300,N,8,1"
End If
' Ouverture du port
On Error Resume Next
oCom.PortOpen = True
If Err Then
st = "COM" + Str(oCom.CommPort) + " n'est pas disponible. "
st = st + "Utilisez le menu Port pour sélectionner un autre port de communication."
MsgBox st
RbCallNumber = False
End If
' Purge du tampon d'entrée
oCom.InBufferCount = 0
' Composition du numéro
Cde = "ATDT " + sOpsPhoneNumber + ";" + Chr$(13)
oCom.Output = Cde
' Attente de la chaîne boPbHangDown en provenance du modem
boPbHangDown = False
Do
' Si il y a des données dans la tampon, les lit.
If oCom.InBufferCount Then
DoEvents
modem = modem + oCom.Input
' If InStr(modem, "OK") <> 0 Then
' MsgBox "Décrochez le téléphone et appuyez sur le bouton Ok."
' DoEvents
' 'oPbHangDown = True
' End If
End If
DoEvents
Loop Until oPbHangDown
' Déconnection du modem
oCom.Output = "ATH" + Chr$(13)
' Fermeture du port
oCom.PortOpen = False
End Function
Private Sub Class_Initialize()
oColor_Good = &H0
oColor_Bad = &H808080
bOpbStandard = True
sOpsPortSetting = "300,N,8,1"
sOpsPhoneNumber = ""
iOpiPortNumber = 1
Set oVoice = New SpVoice
End Sub
Private Sub Class_Terminate()
On Error Resume Next
' Fermeture du port
oCom.PortOpen = False
Set oVoice = Nothing
Set oCom = Nothing
End Sub
'*** Méthode
' ***********************************************************
' FONCTION: DialNumber()
'
' Explication : Composer un numéro de tel en utilisant le modem du PC
'
' Paramètre:
' PhoneNumber: Numéro de tel à composer
'
' ***********************************************************
Public Function DialNumber(PhoneNumber)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
Dim RetVal As Long
' Demande à l'utilisateur de décrocher le téléphone.
Msg = "SVP, décrocher le combiner et cliquer OK pour composer le numéro " _
& PhoneNumber
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Numéro de Tel"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If
' Envoyer le numéro de tel par modem.
RetVal = tapiRequestMakeCall(PhoneNumber, "Phone", "", "")
If RetVal < 0 Then
Msg = "Impossible de composer le numéro " & PhoneNumber
GoTo Err_DialNumber
End If
Exit Function
Err_DialNumber:
Msg = Msg & vbCr & vbCr & _
"Vérifiez que le Port série n'est pas utilisé par un autre utilisateur"
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Erreur lors de la composition du numéro"
MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function
Public Sub sbTextToSpeech(strMessage As String)
On Error GoTo ErrSpeech
'Declarations
'
''Code:
'oVoice.Speak strMessage, SVSFlagsAsync
'
''This will speak to default out put audio device (speaker)
''In case you want to direct the speech to telephone
''Add a MSCom control to your project
''Dial a telephone number
''Once picked up on other side [You need to know AT commands]
''set the oVoice output to telephone object and play the stream
'
oVoice.AllowAudioOutputFormatChangesOnNextSet = False
oVoice.AudioOutputStream.Format.Type = 6
Set oVoice.AudioOutputStream = oVoice.AudioOutputStream
Set oVoice.Voice = oVoice.GetVoices().Item(0)
Set oVoice.AudioOutput = oVoice.GetAudioOutputs().Item(1) '"Your telephone object"
Debug.Print oVoice.AudioOutput.GetDescription
oVoice.Speak strMessage, SVSFlagsAsync Or SVSFPurgeBeforeSpeak Or SVSFIsXML ' SVSFDefault ' Flags
Exit Sub
ErrSpeech:
MsgBox Err.Description
End Sub
Conclusion
Il est en cours de conception. Je dois l'améliorer.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
VB.NET ET COMBOBOXVB.NET ET COMBOBOX par minouthebreaker
Cliquez pour lire la suite par minouthebreaker
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|