Os agradecemos vuestras pruebas y feedback para afinarlo. Gracias!
- Code: Select all Expand view RUN
- FUNC SendToWhatsApp( cPhone, cMsg, aAttach )
LOCAL oShell, aFiles := {}, aOthers := {}, lRet
If (lRet := !Empty( cPhone ))
If !Empty( aAttach )
If( !HB_ISARRAY( aAttach ), aAttach := { aAttach }, )
AEval( aAttach, {|cFile| If( HB_ISSTRING( cFile ) .AND. File( cFile ), AAdd( aFiles, cFile), AAdd( aOthers, cFile ) ) } )
EndIf
cMsg := StrTran( cMsg, CRLF, "%0D%0A" )
oShell := CreateObject( "WScript.Shell" )
ShellExecute( 0, "Open", "whatsapp://send?phone="+cPhone+"&text="+cMsg)
SysWait( 0.2 )
If !Empty( aFiles )
If FW_CopyToClipBoard( aFiles, 15 )
SysWait( 2 )
oShell:SendKeys( "^v" )
SysWait( 1 )
EndIf
EndIf
AEval( aOthers, <|u|
If FW_CopyToClipBoard( u, 2 ) .OR. FW_CopyToClipBoard( u )
SysWait( 1 )
oShell:SendKeys( "^v" )
SysWait( 1 )
EndIf
RETURN NIL
> )
oShell:SendKeys("~")
EndIf
RETURN lRet