FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour whatsapp
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
whatsapp
Posted: Fri Nov 17, 2023 08:44 PM

Buena tarde... tengo la versi贸n 23.05... es posible obtener la clase whatpSapp, mencionada en la 煤ltima version de fwh---

Gracias

JONSSON RUSSI

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: whatsapp
Posted: Sun Nov 19, 2023 02:44 AM
The function provided with FWH2310 can send files as attachments. That is possible only due to some low level ( c language modules ) in FWH2310. So, that is not compatible with earlier versions.

We provide here a modified version with which we can send messages and also some images optionally. This works with FWH2304.
Code (fw): Select all Collapse
// whatsapp app must be installed and opened before running this code

#include "FiveWin.ch"

#define ORANGES "https://www.jesmondfruitbarn.com.au/wp-content/uploads/2016/10/Jesmond-Fruit-Barn-Oranges.jpg"

function Main()

聽 聽local cPhone 聽 := ""
聽 聽local cMsg 聽 聽 := "Hello"

聽 聽if EDITVARS cPhone, cMsg
聽 聽 聽 SendToWhatsApp( AllTrim( cPhone ), AllTrim( cMsg ), ;
聽 聽 聽 聽 聽{ "..\bitmaps\007.bmp", ORANGES, ;
聽 聽 聽 聽 聽 聽 "https://www.google.co.in/" } )
聽 聽endif

return nil


function SendToWhatsApp( cPhone, cMsg, aAttach )

聽 聽local oShell, hBmp
聽 聽local aSend := {}

聽 聽if Empty( cPhone ); return .f.; endif

聽 聽DEFAULT cMsg := "Hello"

聽 聽if !Empty( aAttach )
聽 聽 聽 if !HB_ISARRAY( aAttach ); aAttach := { aAttach }; endif
聽 聽 聽 AEval( aAttach, <|c,i|
聽 聽 聽 聽 聽if HB_ISSTRING( c )
聽 聽 聽 聽 聽 聽 if !Empty( hBmp := FW_ReadImage( nil, c, , .t. )[ 1 ] )
聽 聽 聽 聽 聽 聽 聽 聽AAdd( aSend, hBmp )
聽 聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽 聽AAdd( aSend, CRLF + c )
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽return nil
聽 聽 聽 聽 聽> )
聽 聽endif

聽 聽cMsg 聽:= StrTran( cMsg, CRLF, "%0D%0A" )

聽 聽oShell := CreateObject( "WScript.Shell" )
聽 聽ShellExecute( 0, "Open", "whatsapp://send?phone="+cPhone+"&text="+cMsg )
聽 聽SysWait( 0.5 )


聽 聽AEval( aSend, <|u|
聽 聽 聽 if FW_CopyToClipBoard( u )
聽 聽 聽 聽 聽SysWait( 1 ); oShell:SendKeys( "^v" ); SysWait( 1 )
聽 聽 聽 endif
聽 聽 聽 return nil
聽 聽 聽 > )

聽 聽oShell:SendKeys("~")

return nil
You are welcome to make any improvements.
With this we can send weblinks also.

We need to install WhatsApp application and install and open it.
Regards



G. N. Rao.

Hyderabad, India
Posts: 492
Joined: Wed Nov 16, 2005 12:03 PM
Re: whatsapp
Posted: Sun Nov 19, 2023 09:19 AM

hBitmap = NViewLib32( cBmpFile , 1 )

Vs

FW_ReadImage( nil, cBmpFile, , .t. )

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: whatsapp
Posted: Mon Nov 20, 2023 01:13 PM

We do not know other libraries

But FWH's FW_ReadImage() is very powerful than any.

Regards



G. N. Rao.

Hyderabad, India
Posts: 492
Joined: Wed Nov 16, 2005 12:03 PM
Re: whatsapp
Posted: Wed Nov 22, 2023 08:48 AM

Saludos buen dia y gracias.

Tengo aplicaci贸n con FW 2.4 con usuarios en producci贸n y tiene personalizaciones, para este caso necesito copiar la Imagen hacia el clipboard del OS, cuento con la funcion NViewLib32( cBmpFile , 1 ) que devuelve un valor num茅rico. Necesito copiar la imagen hacia el clibboard del OS.

Igualmente posee FW actualizado y estamos compilando el nuevo binario

Posts: 492
Joined: Wed Nov 16, 2005 12:03 PM
Re: whatsapp
Posted: Wed Nov 22, 2023 01:09 PM

Saludos y gracias a la ayuda de jose Alberto alvares, voy a validar con METHOD CopyToClipboard() CLASS TBitmap

local oClipboard := TClipboard():New( CF_BITMAP )

oClipboard:SetBitmap( Self )

oClipboard:End()

return nil

Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: whatsapp
Posted: Thu Nov 23, 2023 12:22 PM

Buen d铆a...

Funciona perfecto... pero tengo necesidad de enviar PDF... La idea es generar una factura y dar la opci贸n de enviar a whatsApp.

Gracias

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: whatsapp
Posted: Thu Nov 23, 2023 02:38 PM

If you have FWH2310, you can send images and any files as attachments, pdf, etc

Regards



G. N. Rao.

Hyderabad, India
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: whatsapp
Posted: Sat Nov 25, 2023 03:53 PM

Buen dia..

He actualizado a la fwh 23.10 y funciona perfecto....

Gracias

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: whatsapp
Posted: Sat Nov 25, 2023 05:12 PM

If you are using FWH2310, please see fwh\samples\whatsapp.prg

Use the function given in that sample program, but not the program I posted above.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion