Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whatsapp not working 1

Status
Not open for further replies.

sapan.belel

Programmer
Apr 9, 2023
1
IN
Hello,

I have been using the below code to send images to whatsapp from Tariqbhai. Now with new whatsapp updates ,it is activatng whatsapp but not sending
messages and images.

Help needed please.

*-----------------------------------------*

PARAMETERS ltype,lser_no,lreport

Clear
Set Safety Off

Public yout
Do select_frx
Do image_to_clip

Procedure select_frx
*m.yrep=Getenv("TEMP")
*Set Defa To (yrep)

xflname = ALLTRIM(MCOMPANY)+"\WHATSAPP\" + DTOC(DATE(),1)+[_]+CHRTRAN(TIME(),[:],[])

m.yout=xflname

If !Directory(m.yout)
* Md (m.yrep+'\'+xflname)
Md (m.yout) &&+'\'+xflname)
Endif

Local afile
*afile=Getfile('frx')

&& you can this following line for testing purpose
afile=CURDIR() + "\reports\" + lreport

If !Empty(m.afile)
m.ext=Lower(Justext(m.afile))
If m.ext<>[frx]
Messagebox('Please select only frx',0+16,'Whatsapp',3000)
Return
Endif
Else
Messagebox('Report not selected',0+64,'Whatsapp',3000)
Return
Endif

#Define OutputNothing -1
#Define OutputEMF 100
#Define OutputJPEG 102
#Define OutputGIF 103
#Define OutputPNG 104
#Define OutputBMP 105
#Define OutputTIFF 101
#Define OutputTIFFM 201

oListener =Newobject("ReportListener")
oListener.ListenerType=3
Report Form (afile) Preview Object oListener

myext=[.]+Alltrim('JPG')
ntype=OutputJPEG
m.yout=m.yout

For nPageno=1 To oListener.PageTotal
cOutputFile = m.yout + Trans(nPageno)+myext
* cOutputFile = "BIll" +Trans(nPageno)+myext &&+ CURDIR() + ALLTRIM(mcompany) + "_B_" + ALLTRIM(STR(tempcur.ser_no))+Trans(nPageno)+myext

* cOutputFile = m.yout+"\myreport" +"_PATTI_" + ALLTRIM(STR(TEMPCUR.s_billno)) + Trans(nPageno)+myext
cOutputFile = m.yout+"\myreport" +"_" + ALLTRIM(LTYPE)+ "_" + ALLTRIM(STR(lser_no)) + Trans(nPageno)+myext

oListener.OutputPage(nPageno, cOutputFile,m.ntype)

oListener.OutputPage(nPageno, cOutputFile,m.ntype)
Next

*!* If Not Inlist(ntype,OutputTIFFM,1000,1001)
*!* Run/N "explorer" &yout
*!* Endi

reporlistener=Null
Release ReportListener
Endproc

Procedure image_to_clip

Declare Integer Sleep In kernel32 Integer
Declare Integer OpenClipboard In User32 Integer
Declare Integer CloseClipboard In User32
Declare Integer EmptyClipboard In User32
Declare Integer SetClipboardData In User32 Integer,Integer
Declare Integer LoadImage In WIN32API Integer,String,Integer,Integer,Integer,Integer
Declare Integer GetClipboardData In User32 Integer
Declare Integer GdipCreateBitmapFromHBITMAP In GDIPlus.Dll Integer, Integer, Integer @
Declare Integer GdipSaveImageToFile In GDIPlus.Dll Integer,String,String @,String @
Declare Long GdipCreateHBITMAPFromBitmap In GDIPlus.Dll Long nativeImage, Long @, Long
Declare Long GdipCreateBitmapFromFile In GDIPlus.Dll String FileName, Long @nBitmap
Declare Long GdipCreateBitmapFromFile In GDIPlus.Dll String FileName, Long @nBitmap
Declare Long CopyImage In WIN32API Long hImage, Long, Long, Long , Long

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

#Define CF_BITMAP 2
#Define CF_DIB 8
#Define IMAGE_BITMAP 0
#Define LR_LOADFROMFILE 16
#Define LR_MONOCHROME 0x00000001


fso=Createobject("scripting.filesystemobject")
fld=fso.getfolder(yout)

For Each fil In fld.Files

Local m.oo
m.oo=Newobject("image")
m.oo.Picture=m.yout+"\"+(fil.Name)

Local lnWidth,lnHeight
lnWidth=m.oo.Width
lnHeight=m.oo.Height

nBitmap=0
hbm=0
GdipCreateBitmapFromFile(Strconv(m.yout+"\"+(fil.Name)+0h00,5),@nBitmap)
GdipCreateHBITMAPFromBitmap(nBitmap,@hbm,0)
lhBmp = CopyImage(hbm, 0, m.lnWidth, m.lnHeight,0)
If OpenClipboard(0)!= 0
EmptyClipboard()
SetClipboardData(CF_BITMAP, lhBmp)
CloseClipboard()
Endif

Local lt, lhwnd
cPhone= "[" + ALLTRIM(tempcur.mob_no) + "]" && [919821384150] && ALLTRIM(tempcur.mobile) &&
cmd='whatsapp://send?phone=&cPhone'
=ShellExecute(0, 'open', cmd,'', '', 1)
Wait "" Timeout 3
lt = "Whatsapp"
lhwnd = FindWindow (0, lt)
If lhwnd!= 0
SetForegroundWindow (lhwnd)
ShowWindow (lhwnd, 1)
ox = Createobject ( "Wscript.Shell" )
ox.sendKeys ("^{v}")
Sleep(2000)
ox.sendKeys ( '{ENTER}' )
Else
Messagebox ("Whatsapp is not activated!" )
Endif
Next

Endproc

PARAMETERS ltype,lser_no,lreport

Clear
Set Safety Off

Public yout
Do select_frx
Do image_to_clip

Procedure select_frx
*m.yrep=Getenv("TEMP")
*Set Defa To (yrep)

xflname = ALLTRIM(MCOMPANY)+"\WHATSAPP\" + DTOC(DATE(),1)+[_]+CHRTRAN(TIME(),[:],[])

m.yout=xflname

If !Directory(m.yout)
* Md (m.yrep+'\'+xflname)
Md (m.yout) &&+'\'+xflname)
Endif

Local afile
*afile=Getfile('frx')

&& you can this following line for testing purpose
afile=CURDIR() + "\reports\" + lreport

If !Empty(m.afile)
m.ext=Lower(Justext(m.afile))
If m.ext<>[frx]
Messagebox('Please select only frx',0+16,'Whatsapp',3000)
Return
Endif
Else
Messagebox('Report not selected',0+64,'Whatsapp',3000)
Return
Endif

#Define OutputNothing -1
#Define OutputEMF 100
#Define OutputJPEG 102
#Define OutputGIF 103
#Define OutputPNG 104
#Define OutputBMP 105
#Define OutputTIFF 101
#Define OutputTIFFM 201

oListener =Newobject("ReportListener")
oListener.ListenerType=3
Report Form (afile) Preview Object oListener

myext=[.]+Alltrim('JPG')
ntype=OutputJPEG
m.yout=m.yout

For nPageno=1 To oListener.PageTotal
cOutputFile = m.yout + Trans(nPageno)+myext
* cOutputFile = "BIll" +Trans(nPageno)+myext &&+ CURDIR() + ALLTRIM(mcompany) + "_B_" + ALLTRIM(STR(tempcur.ser_no))+Trans(nPageno)+myext

* cOutputFile = m.yout+"\myreport" +"_PATTI_" + ALLTRIM(STR(TEMPCUR.s_billno)) + Trans(nPageno)+myext
cOutputFile = m.yout+"\myreport" +"_" + ALLTRIM(LTYPE)+ "_" + ALLTRIM(STR(lser_no)) + Trans(nPageno)+myext

oListener.OutputPage(nPageno, cOutputFile,m.ntype)

oListener.OutputPage(nPageno, cOutputFile,m.ntype)
Next

*!* If Not Inlist(ntype,OutputTIFFM,1000,1001)
*!* Run/N "explorer" &yout
*!* Endi

reporlistener=Null
Release ReportListener
Endproc

Procedure image_to_clip

Declare Integer Sleep In kernel32 Integer
Declare Integer OpenClipboard In User32 Integer
Declare Integer CloseClipboard In User32
Declare Integer EmptyClipboard In User32
Declare Integer SetClipboardData In User32 Integer,Integer
Declare Integer LoadImage In WIN32API Integer,String,Integer,Integer,Integer,Integer
Declare Integer GetClipboardData In User32 Integer
Declare Integer GdipCreateBitmapFromHBITMAP In GDIPlus.Dll Integer, Integer, Integer @
Declare Integer GdipSaveImageToFile In GDIPlus.Dll Integer,String,String @,String @
Declare Long GdipCreateHBITMAPFromBitmap In GDIPlus.Dll Long nativeImage, Long @, Long
Declare Long GdipCreateBitmapFromFile In GDIPlus.Dll String FileName, Long @nBitmap
Declare Long GdipCreateBitmapFromFile In GDIPlus.Dll String FileName, Long @nBitmap
Declare Long CopyImage In WIN32API Long hImage, Long, Long, Long , Long

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

#Define CF_BITMAP 2
#Define CF_DIB 8
#Define IMAGE_BITMAP 0
#Define LR_LOADFROMFILE 16
#Define LR_MONOCHROME 0x00000001


fso=Createobject("scripting.filesystemobject")
fld=fso.getfolder(yout)

For Each fil In fld.Files

Local m.oo
m.oo=Newobject("image")
m.oo.Picture=m.yout+"\"+(fil.Name)

Local lnWidth,lnHeight
lnWidth=m.oo.Width
lnHeight=m.oo.Height

nBitmap=0
hbm=0
GdipCreateBitmapFromFile(Strconv(m.yout+"\"+(fil.Name)+0h00,5),@nBitmap)
GdipCreateHBITMAPFromBitmap(nBitmap,@hbm,0)
lhBmp = CopyImage(hbm, 0, m.lnWidth, m.lnHeight,0)
If OpenClipboard(0)!= 0
EmptyClipboard()
SetClipboardData(CF_BITMAP, lhBmp)
CloseClipboard()
Endif

Local lt, lhwnd
cPhone= "[" + ALLTRIM(tempcur.mob_no) + "]" && [919821384150] && ALLTRIM(tempcur.mobile) &&
cmd='whatsapp://send?phone=&cPhone'
=ShellExecute(0, 'open', cmd,'', '', 1)
Wait "" Timeout 3
lt = "Whatsapp"
lhwnd = FindWindow (0, lt)
If lhwnd!= 0
SetForegroundWindow (lhwnd)
ShowWindow (lhwnd, 1)
ox = Createobject ( "Wscript.Shell" )
ox.sendKeys ("^{v}")
Sleep(2000)
ox.sendKeys ( '{ENTER}' )
Else
Messagebox ("Whatsapp is not activated!" )
Endif
Next

Endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top