×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Whatsapp not working

Whatsapp not working

Whatsapp not working

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close