Created
July 2, 2020 23:00
-
-
Save rauljrz/68c6215d717dbde2a746b87e19b277a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** Função PARA ENVIAR WHATSAPP | |
** | |
** Parametros: | |
** PC_FONE DDD+FONE | |
** PC_MENSAGEM Mensagem a enviar | |
** | |
** | |
** | |
FUNCTION WHATSAPP | |
PARAMETERS PC_FONE, PC_MENSAGEM,PC_IMAGEM | |
TRY | |
VC_FONE =[+55]+ALLTRIM(STRTRAN(STRTRAN(STRTRAN(PC_FONE,"-","")," ",""),".","")) | |
IF VARTYPE(PC_IMAGEM) <> 'C' | |
NomeDaImagemBMP =[] | |
ELSE | |
NomeDaImagemBMP = PC_IMAGEM &&'D:\TMP\LOGO.BMP' informar a imagem BMP | |
ENDIF | |
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 | |
LOCAL lt, lhwnd | |
********** | |
* Carga Whatsapp | |
********** | |
comando='whatsapp://send?phone='+vc_fone+'&text='+PC_MENSAGEM | |
=ShellExecute(0, 'open', Comando,'', '', 1) | |
WAIT "" TIMEOUT 1 | |
lt = "Whatsapp" | |
lhwnd = FindWindow (0, lt) | |
IF lhwnd!= 0 && se estiver com o formulario do WhatsApp ativo | |
SetForegroundWindow (lhwnd) && Foca no fomulario do Whatsapp | |
ShowWindow (lhwnd, 1) | |
ox = CREATEOBJECT ( "Wscript.Shell" ) | |
IF !EMPTY(NomeDaImagemBMP) | |
THIS.CTRL_C_BMP( NomeDaImagemBMP ) | |
Inkey(1) | |
ox.sendKeys ( "^{v}" ) | |
ENDIF | |
Inkey(1) | |
ox.sendKeys ( '{ENTER}' ) | |
*vgo_msg.erro("Mensagem enviada com Sucesso") | |
ELSE | |
*vgo_msg.erro("Mensagem não enviada") | |
ENDIF | |
CATCH TO EXI | |
MESSAGEBOX(EXI.MESSAGE) | |
ENDTRY | |
ENDFUNC | |
** Função PARA ENVIAR anexo no WHATSAPP | |
** | |
** Parametros: | |
** cImageBMP Caminho da imagem exemplo c:\x\arquivo.bmp | |
** | |
FUNCTION CTRL_C_BMP( cImageBMP ) | |
Local lOk | |
Declare Long OpenClipboard in User32 Long nhWnd | |
Declare Long EmptyClipboard in User32 | |
Declare Long CloseClipboard in User32 | |
Declare Long SetClipboardData in User32 Integer nFormat, Long hMem | |
Declare Long LoadImage in User32 ; | |
Long hInst, String cFilename, Integer nType, ; | |
Integer cxDesired, Integer cyDesired, Integer fuLoad | |
lOk = .F. | |
*hBitmap = LoadImage(0, lc_Filename, 0, 0,0, 0x10) | |
hBitmap = LoadImage(0, cImageBMP, 0, 0,0, 0x10) | |
If (hBitmap != 0) | |
OpenClipboard(0) | |
EmptyClipboard() | |
SetClipboardData(2, hBitmap) | |
CloseClipboard() | |
lOk = .T. | |
endif | |
Return lOk | |
ENDFUNC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Muito bom, parabéns