Page 4 of 4

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Fri Oct 27, 2023 4:10 pm
by cmsoft
nageswaragunupudi wrote:I am asking your help to finalize this.

No me esta funcionando el envio de adjuntos.
Sera porque tengo la version desactualizada?

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Fri Oct 27, 2023 4:38 pm
by cmsoft
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

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Fri Oct 27, 2023 7:28 pm
by Giovany Vecchi
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: Select all  Expand view
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
 

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Fri Oct 27, 2023 7:53 pm
by sysctrl2
Estaría super unos Wrapers para API Green, :lol:

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Fri Oct 27, 2023 11:12 pm
by cmsoft
Esta es la funcion Fw_CopyToClipboar que tengo en mi versión, creo que no esta considerando array de archivos.
Code: Select all  Expand view

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
 

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sat Oct 28, 2023 1:35 am
by nageswaragunupudi
What is your FWH version?

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sat Oct 28, 2023 1:42 am
by nageswaragunupudi
You can also try WhatsApp business
https://business.whatsapp.com/

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sat Oct 28, 2023 1:54 am
by nageswaragunupudi
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.

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sat Oct 28, 2023 2:42 pm
by nageswaragunupudi
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: Select all  Expand view

#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
[code]   oShell:SendKeys("{DOWN}") // Presiono flecha abajo
   syswait(.2)
 /code]

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sun Oct 29, 2023 8:53 am
by nageswaragunupudi

Re: enviar mensajes a whatsapp, ¿posible solucion?

PostPosted: Sun Oct 29, 2023 1:11 pm
by cmsoft
Muchas gracias Mr. Rao.