Este codigo hace mucho que lo hice ( para ayudar en el foro elhacker net a un usuario hace ya como 1/2 de año ).

Codigo y Post original:

Código: Seleccionar todo


http://foro.elhacker.net/programacion_visual_basic/mscomm_manejar_el_celular_desde_la_pc-t320786.0.html;msg1586274#msg1586274

Alternativa al OCX.
[Enlace externo eliminado para invitados].

Código: Seleccionar todo


http://infrangelux.sytes.net/FileX/?file=clsCom.cls&dir=/BlackZeroX/Programacion/vb6/Modulos%20de%20Clase/Puertos%20Com

Código: Seleccionar todo


Option Explicit
 
Private WithEvents obj_clscom           As clsCom
 
'
'   /////////////////////////////////////////////////////////////
'   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
'   //                                                         //
'   // Web:     http://InfrAngeluX.Sytes.Net/                  //
'   //                                                         //
'   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
'   // no se eliminen los creditos originales de este codigo   //
'   // No importando que sea modificado/editado o engrandecido //
'   // o achicado, si es en base a este codigo                 //
'   /////////////////////////////////////////////////////////////
'   // http://infrangelux.sytes.net/Blog/index.php?option=com_content&view=article&id=6:artwait&catid=2:catprocmanager&Itemid=8
'   /////////////////////////////////////////////////////////////

Private Declare Function WaitMessage Lib "user32" () As Long
 
Enum eTime
    Horas = 3600
    Minutos = 60
    Segundos = 1
End Enum
 
Public Sub Wait(ByVal vToWait&, Optional ByVal ThisWait As eTime = Segundos, Optional ByVal UseAllProc As Boolean = False)
Dim vDateE      As Date
    vDateE = DateAdd("s", vToWait& * (ThisWait + 0), Time)
    Do While vDateE > Time
        Call WaitMessage
        If Not UseAllProc Then DoEvents
    Loop
End Sub
Private Sub Form_Load()
    Set obj_clscom = New clsCom
    With obj_clscom
        .ComPort = 4
        .ComSettings = "57600,N,8,1"    ' 57600 bps, sin paridad, 8 bits de data, 1 bit de stop
        .TimerDelay = 1000              ' 1000ms = 1 Segundo para chequear si entro data
        .TimerEnabled = True
        If .InitCom Then
            Call .WriteCom("AT" & vbCr)
' wait()
            Call .WriteCom("AT+CMGF=1" & vbCr)
' wait()
            Call .WriteCom("AT+CMGS=" & Chr(34) & "0445526651140" & Chr(34) & vbCr) ' // Segun el protocolo lo que nos retorna es +CMGS: <Num. Identificador>
' wait()
            Call .WriteCom("Espero una jalada en mi cel, aun que ya no tengo credito xP" & Chr(26))    ' 26 = Ctrl+Z ( Segun el protocolo AT )
        End If
    End With
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
    Set obj_clscom = Nothing
End Sub
 
Private Sub obj_clscom_DataReceived(ByVal strData As String)
    Debug.Print strData
    If InStr(1, strData, "+CMGS:") > 0 Then
        If InStr(1, strData, "OK") > 0 Then
            Dim str_Ret()       As String
            str_Ret() = Split(Replace(Replace(strData, vbCr, ""), "OK", ""), " ")
            Call obj_clscom.WriteCom("AT+CMSS=" & Val(str_Ret(1)) & vbCr)
        End If
    End If
End Sub

Web: http://infrangelux.sytes.net/
ScanX: http://ScanX.sytes.net/
FileX: http://FileX.sytes.net/
Blog: http://BlogX.sytes.net/

Imagen


The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi religion
Responder

Volver a “Fuentes”