FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour enviar mensajes a whatsapp, ¿posible solucion?
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Fri Oct 27, 2023 04:10 PM
nageswaragunupudi wrote: I am asking your help to finalize this.
No me esta funcionando el envio de adjuntos.
Sera porque tengo la version desactualizada?
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Fri Oct 27, 2023 04:38 PM
JoseAlvarez wrote:WhatsApp podria banear la cuenta desde la cual se realizan los envíos, si el uso es continuo, de mucho volumen de mensajes o la cantidad de destinatarios sea grande, en cada ciclo de mensajes emitidos. Tal es el caso de mi aplicacion.
Por la experiencia que yo he podido recabar del tema de envíos masivos, el problema principal es que los número de teléfono no estén agendados en el propietario que envía esos mensajes, y también depende que los receptores de dichos mensajes, denuncien como span dicho mensaje.
De lo contrario, no hemos tenido problemas con bloqueos por parte de Whatsapp
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Fri Oct 27, 2023 07:28 PM
Hola gente.
Utilizo una alternativa con la aplicación file2clip.exe que copia cualquier tipo de archivo al clipboard de Windows.
El proyecto está aquí: https://github.com/rostok/file2clip

Y a continuación se muestra la función:
Code (fw): Select all Collapse
FUNCTION WHATS_APP_GO_DIRECT(f_cPhoneNumber,f_cMessage,f_cFileSend,f_cCountryCode)
   Local lc_cCommandStart     := ""
   Local lc_cCommandTxt       := ""
   Local lc_cCommandFile      := ""
   Local lc_oClipBoard
   Local lc_hWndWhats
   Local lc_oShellScr
   Local lc_oShellFolder     
   Local lc_iFor           := 0 

   Default f_cMessage := "", f_cFileSend := "", f_cCountryCode := "55"
   
    lc_cCommandStart  := "whatsapp://send?phone=_cPhoneNumber_" 
   lc_cCommandTxt    := "whatsapp://send?phone=_cPhoneNumber_&text=_cMessage_" 
   lc_cCommandFile   := Hb_DirBase()+"file2clip.exe _cFileSend_" 
   
   f_cPhoneNumber    := StrTran(f_cPhoneNumber," ","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,"(","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,")","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,",","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,"-","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,".","")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,"+"+f_cCountryCode,"")
   f_cPhoneNumber    := StrTran(f_cPhoneNumber,"+","")
   f_cPhoneNumber    := f_cCountryCode+f_cPhoneNumber
   
   f_cMessage        := StrTran(f_cMessage,CRLF,"%0A")
   f_cMessage        := StrTran(f_cMessage," ","%20")
   f_cMessage        := StrTran(f_cMessage,"&","%26")
   f_cMessage        := StrTran(f_cMessage,chr(13),"%0D%0A")

   If !Empty(f_cFileSend)
      f_cFileSend    := Lfn2Sfn(f_cFileSend)
      f_cFileSend    := chr(34)+f_cFileSend+chr(34)
   EndIf

   lc_cCommandStart  := StrTran(lc_cCommandStart,"_cPhoneNumber_",f_cPhoneNumber)

   lc_cCommandTxt    := StrTran(lc_cCommandTxt,"_cPhoneNumber_",f_cPhoneNumber)
   lc_cCommandTxt    := StrTran(lc_cCommandTxt,"_cMessage_",f_cMessage)

   lc_cCommandFile   := StrTran(lc_cCommandFile,"_cFileSend_",f_cFileSend)

   ShellExecute(0,"open",lc_cCommandStart)
   syswait(2)
   
   lc_hWndWhats := FindWindow(,"WhatsApp")

   if hb_IsNil(lc_hWndWhats)
      MsgStop("WhatsApp não esta carregado.","Procedimento abortado.")
      Return .F.
   Else
      if lc_hWndWhats == 0
         MsgStop("WhatsApp não esta carregado.","Procedimento abortado.")
         Return .F.

      Else
         BringWindowToTop( lc_hWndWhats )
         SysWait(.3)
      EndIf
   EndIf  

   //? lc_cCommandTxt
   
   lc_oShellScr         := tOleAuto():New( "WScript.Shell" )
   
   If !Empty(f_cMessage)
      ShellExecute(0,"open",lc_cCommandTxt)
      syswait(.5)
      lc_oShellScr:SendKeys( "~" )
   EndIf

   //? lc_cCommandFile

   If !Empty(f_cFileSend)
      WaitRun(lc_cCommandFile,0)
      syswait(.4)
      lc_oShellScr:SendKeys( "^v" )
      syswait(1)      
      lc_oShellScr:SendKeys( "~" )
      syswait(.5)      
   EndIf


RETURN NIL
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Fri Oct 27, 2023 07:53 PM
Estaría super unos Wrapers para API Green, :lol:
Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Fri Oct 27, 2023 11:12 PM
Esta es la funcion Fw_CopyToClipboar que tengo en mi versión, creo que no esta considerando array de archivos.
Code (fw): Select all Collapse
function FW_CopyToClipBoard( uValue, nFormat )

   local lCopied  := .f.

   if HB_ISPOINTER( uValue ) // assumes GDI+ Image object
      GDIPLUSImageToClipBoard( uValue )
      return .t.
   endif

   if uValue != nil
      DEFAULT nFormat := If( HB_ISSTRING( uValue ), 1, ;
                         If( HB_ISNUMERIC( uValue ) .and. ISHBITMAP( uValue ), ;
                         2, nil ) )
      if nFormat != nil
         if OpenClipBoard( GetDeskTopWindow() )
            EmptyClipboard()
            lCopied  := SetClipboardData( nFormat, uValue )
            CloseClipboard()
         endif
      endif
   endif

return lCopied
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sat Oct 28, 2023 01:35 AM

What is your FWH version?

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sat Oct 28, 2023 01:42 AM
You can also try WhatsApp business
https://business.whatsapp.com/
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sat Oct 28, 2023 01:54 AM
Esta es la funcion Fw_CopyToClipboar que tengo en mi versión, creo que no esta considerando array de archivos.
Possible from FWH2307 onwards only.
This is because the C level improvements for CF_HDROP were implemented in FWH2307 only that are necessary for copy multiple files to clipboard. (fwh\source\winapi\clpbrd.c)

We will test and include the above function as a sample in FWH2310.

At the same time, we will work on a function that will work with all older versions also now.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sat Oct 28, 2023 02:42 PM
cmsoft wrote:Jose:
Esta es una manera de enviar mensajes con documentos adjuntos.
Lo que debes hacer es emular el uso de teclado en la aplicación de Whatsapp
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
local oShell                                                        
   ShellExecute( 0, "open", "whatsapp://send?phone=111111111111&text=Estimado Sr. Antonio Linares.%0A"+;
    "Gusto en Saludarle, "+ Time() ) 
   oShell := CreateObject( "WScript.Shell" )
   syswait(.2)
   oShell:SendKeys( "~" ) //Doy enter para que envie el mensaje
   syswait(2)
   oShell:SendKeys("+{TAB}") //Presiono Shift Tab para que vaya a adjuntar 
   syswait(.2)
   oShell:SendKeys("~") //Doy enter
   syswait(.2)
   oShell:SendKeys("{DOWN}") // Presiono flecha abajo
   syswait(.2)
   oShell:SendKeys("~")  // Doy enter
   syswait(2)
   oShell:SendKeys("c:\fwh21\samples\prueba.pdf") // Escribo el nombre del documento adjunto
   syswait(.2)
   oShell:SendKeys("~") // Doy enter
   syswait(4)
   oShell:SendKeys("~") // Doy enter
   syswait(.2)
   oShell:SendKeys("{TAB}") // Presiono TAB para que vuelva a la casilla de escritura de mensajes
return nil
Si falla, puedes cambiar los tiempos de espera entre cada acción, solo es cuestion de ir probando.
Espero que te sirva
For versions prior to 2307, this approach is very nice.

For sending Image Files like jpg,bmp,png,etc.
skip these three lines
   oShell:SendKeys("{DOWN}") // Presiono flecha abajo
   syswait(.2)
 /code]
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sun Oct 29, 2023 08:53 AM
Regards



G. N. Rao.

Hyderabad, India
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: enviar mensajes a whatsapp, ¿posible solucion?
Posted: Sun Oct 29, 2023 01:11 PM

Muchas gracias Mr. Rao.

Continue the discussion