Re: enviar mensajes a whatsapp, ¿posible solucion?
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
nageswaragunupudi wrote:I am asking your help to finalize this.
No me esta funcionando el envio de adjuntos.
Sera porque tengo la version desactualizada?
www.FiveTechSoft.com
https://forums.fivetechsupport.com/
https://forums.fivetechsupport.com/viewtopic.php?f=6&t=43787
nageswaragunupudi wrote:I am asking your help to finalize this.
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.
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
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
Esta es la funcion Fw_CopyToClipboar que tengo en mi versión, creo que no esta considerando array de archivos.
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