Whatsapp API/Integration

::share resurse Visualfox: librarii, aplicatii, scripturi diverse. Postati doar resursele si detaliile.
Forum rules
:: limbajul folosit in acest forum va fi unul civilizat, in limita subiectelor din topicurile deschise.
:: orice manifestare necivilizata (agresiune verbala, comportament neadecvat, reclama abuziva fara legatura cu forumul) va duce la stergerea contului de user.
:: pt. inscriere USER NOU la acest FORUM, folositi linkul https://profox.ro/forum-register/
:: IN ACEST TOPIC SE POSTEAZA DOAR RESURSELE SI DETALIILE AFERENTE
:: Nu atasati FISIERE! Inserati linkuri pt. acestea!
Post Reply
User avatar
admin
Posts: 214
Joined: 16 Jun 2022, 17:03

Whatsapp API/Integration

Post by admin »

Salut ! Ce solutii ieftine/simple aveti pt integrarea Whatsapp in programele VFP ? Aveti exemple de cod ?

Noi avem scriptul asta:

procedure fawap

Parameters WAPTEL,WAPMESS,WAPFILE

pdf_filepath = Alltrim(WAPFILE)
WAPTEL=Alltrim(WAPTEL)
WAPMESS=Alltrim(WAPMESS)
ccMessage='. '
_Cliptext = ''

Do wafoxpdf With pdf_filepath

***
Function wafoxpdf
Parameters CFilepath
_Cliptext = CFilepath && Path For PDF
Declare Sleep In kernel32 Integer
Declare Integer FindWindow In WIN32API String , String
Declare Integer SetForegroundWindow In WIN32API Integer
Declare Integer ShowWindow In WIN32API Integer , Integer
Declare Integer ShellExecute In shell32.Dll Integer hndWin, String cAction, String cFileName, String cParams, String cDir, Integer nShowWin

Wait Window '' Timeout 2

Local lt, lhwnd
lt = "Whatsapp"
lhwnd = FindWindow (0, lt)

If lhwnd!= 0
**ESTE DESCHIS WHATSAPP
cPhone=[&waptel]
cmd='whatsapp://send?phone=&cPhone&text='+ccMessage
=ShellExecute(0, 'open', cmd,'', '', 1)

Wait Window "Asteptati...deschid Whatsapp.." Timeout 3

SetForegroundWindow (lhwnd)
ShowWindow (lhwnd, 1)
**1-normal, 2-minimized, 3-maximized
ox = Createobject ( "Wscript.Shell" )
SetForegroundWindow (lhwnd)

**ADAUG 2 BACKTABURI
If XBTAB2>0
For nn=1 To XBTAB2
ox.sendkeys ("+{TAB}")
=Inkey(.5)
Endfor
Endif

**ia text
If !Empty(WAPMESS)
_Cliptext = WAPMESS
=Inkey(.5)
ox.sendkeys ("^{v}")
=Inkey(.5)
Endif

**ia pdf
If !Empty(CFilepath) And File(CFilepath)
_Cliptext = CFilepath
For mm=1 To Len(xtabpdf)
cetab=Substr(xtabpdf,mm,1)
Do Case
Case cetab='T'
ox.sendkeys ("+{TAB}")
=Inkey(.5)
Case cetab='E'
ox.sendkeys ("{ENTER}")
=Inkey(.5)
Case cetab='V'
ox.sendkeys ("^{v}")
=Inkey(.5)
Endcase
Endfor
Endif

**trimite
=Inkey(.5)
ox.sendkeys ("{ENTER}")
=Inkey(1)
Else
*NU ESTE DESCHIS WHATSAPP
cPhone=[&waptel]
cmd='whatsapp://send?phone=&cPhone&text='+ccMessage
=ShellExecute(0, 'open', cmd,'', '', 1)

Wait Window "Asteptati...deschid Whatsapp.." Timeout xtempo4

_Cliptext = CFilepath
lhwnd = FindWindow (0, lt)
If lhwnd!= 0
SetForegroundWindow (lhwnd)
ShowWindow (lhwnd, 1)
**1-normal, 2-minimized, 3-maximized
ox = Createobject ( "Wscript.Shell" )
SetForegroundWindow (lhwnd)
=Inkey(.5)


*CANCEL
**ADAUG 2 BACKTABURI
For nn=1 To xbtab1
ox.sendkeys ("+{TAB}")
=Inkey(.5)
Endfor

**ia text
If !Empty(WAPMESS)
_Cliptext = WAPMESS
ox.sendkeys ("^{v}")
=Inkey(.5)
Endif

**ia pdf
If !Empty(CFilepath) And File(CFilepath)
_Cliptext = CFilepath
For mm=1 To Len(xtabpdf)
cetab=Substr(xtabpdf,mm,1)
Do Case
Case cetab='T'
ox.sendkeys ("+{TAB}")
=Inkey(.5)
Case cetab='E'
ox.sendkeys ("{ENTER}")
=Inkey(.5)
Case cetab='V'
ox.sendkeys ("^{v}")
=Inkey(.5)
Endcase
Endfor
Endif

**trimite
=Inkey(.5)
ox.sendkeys ("{ENTER}")
=Inkey(1)
Else
Messagebox ("Eroare deschidere Whatsapp...")
reusit=.F.
Endif
Endif

dar as vrea sa gasim ceva mai stabil :)))
Post Reply