Antonio,
I make a small test but I have allways errors
Error description: Error BASE/1003 Variable does not exist: AATTACH
My test
#include "fivewin.ch"
#include 'constant.ch'
Function test()
Local oDlg,oFont,oBold
local aGet:=array(10)
local oBtnSel
local cPhone:=space(14)
local cMsg:=space(255)
local aCooDlg := aParamDialog(6)
local nRow:= 40,nCol:= 10
local nInterlinea := 30
oFont := TFont():New( "TAHOMA", 0, 16,, )
oBold := TFont():New( "TAHOMA", 0, 14,,.t. )
DEFINE DIALOG oDlg SIZE aCooDlg[1], aCooDlg[2] PIXEL TRUEPIXEL;
FONT oFont TITLE "test WhatsApp Message" COLOR CLR_BLACK, nRgb( 245,244,234) TRANSPARENT;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX)
@ nRow,nCol Say "Phone :"
nRow-=2
@ nRow,nCol GET aGet[1] VAR cPhone SIZE 200,24 PIXEL of oDlg
@ nRow,nCol+200 BTNBMP oBtnSel FILE "PHONE.png" SIZE 30,23 PIXEL FLAT NOROUND;
ACTION ::ShowPopUp( Options( Self,cPhone,cMsg ) )
oBtnSel:nClrBorder := rgb(210,210,205)
ACTIVATE DIALOG oDlg CENTER ;
ON INIT (oDlg:resize())
RETURN NIL
//---------------------------------------------------------------------//
Function Options (oBtn,cPhone,cMsg)
local oMenu
If Empty(cPhone)
MsgAlert("Devi inserie un numero telefonico")
return nil
Endif
MENU oMenu POPUP
MENUITEM "Messaggio con SMS"
SEPARATOR
MENUITEM "Messaggio con WhathApp" NAME "whatsapp.png" ;
ACTION AskMsg(cMsg,cPhone)
ENDMENU
return oMenu
Function AskMsg(cMsg,cPhone)
If MsgGet("Messaggio da inviare","Messaggio :",cMsg )
SendToWhatsApp( cPhone, cMsg, aAttach )
endif
return nil
//----------------------------------------------------------------------//
FUNC SendToWhatsApp( cPhone, cMsg, aAttach )
LOCAL oShell, aFiles := {}, aOthers := {}, lRet
DEFAULT aAttach := {}
If (lRet := !Empty( cPhone ))
If !Empty( aAttach )
If( !HB_ISARRAY( aAttach ), aAttach := { aAttach }, )
AEval( aAttach, {|cFile| If( HB_ISSTRING( cFile ) .AND. File( cFile ), AAdd( aFiles, cFile), AAdd( aOthers, cFile ) ) } )
EndIf
cMsg := StrTran( cMsg, CRLF, "%0D%0A" )
oShell := CreateObject( "WScript.Shell" )
ShellExecute( 0, "Open", "whatsapp://send?phone="+cPhone+"&text="+cMsg)
SysWait( 0.2 )
If !Empty( aFiles )
If FW_CopyToClipBoard( aFiles, 15 )
SysWait( 2 )
oShell:SendKeys( "^v" )
SysWait( 1 )
EndIf
EndIf
AEval( aOthers, <|u|
If FW_CopyToClipBoard( u, 2 ) .OR. FW_CopyToClipBoard( u )
SysWait( 1 )
oShell:SendKeys( "^v" )
SysWait( 1 )
EndIf
RETURN NIL
> )
oShell:SendKeys("~")
EndIf
RETURN lRet
Function aParamDialog(n)
local nBottom,nRight,nWd,nHt
local aTmp :={0,0}
Do Case
Case n=6
nBottom:= 12 //edit2
nRight := 78
Endcase
nHt := nBottom * DLG_CHARPIX_H
nWd := Max( nRight * DLG_CHARPIX_W, 180 )
aTmp[1]:=nWd
aTmp[2]:=nHt
return aTm
How can you remove the ability to have attachments or not?
then the function should check if the WhatsApp application is installed on the PC and load it directly from the Microsoft store but I don't know how to do it
the link to download is "https://apps.microsoft.com/detail/9nksqgp7f2nh?hl=it-it&gl=IT"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com