Jump to content
Fivewin Brasil

Integração com WEB


fluna

Recommended Posts

Tenho uma rotina em que abro uma página web para mandar recado para clientes no whatsapp; o problema é que ele abre várias janelas em vez de usar uma que já está aberta;

 

  if ..... // já existe janela aberta
       *

       *
    
  Else
     oShell:run("https://web.whatsapp.com/send?phone="+cPara) ; Sleep(nSecs)
  Endif

Alguém poderia me ajudar a resolver isso?  Tipo, se a página já está aberta, usá-la em vez de abrir outra no navegador

Obrigado.

Link to comment
Share on other sites

Quando usava childwindows colocava uma variável estática no inicio do PRG.

#include fivewin.ch

STATIC nJane

FUNCTION XXXX

LOCAL oWndChild

IF nJane = NIL

DEFINE WINDOW oWndCh CHILD OF wndMain() TITLE ....

.

.

.

ACTIVATE WINDOW oWndChild VALID ( nJane :=NIL ) ON INIT ( nJane := 1)

ELSE

oWndChild:Restore()

ENDIF

Link to comment
Share on other sites

Me desculpe, adutheil; talvez eu não tenha me expressado corretamente. A janela a que me refiro é uma página web. O script abre uma nova página web, mesmo que a mesma já esteja aberta no navegador...  Ex: estou com a página do whatszap aberta, mas quando executo o sistema abre outra página do whats em vez de usar a que está aberta.  De qualquer maneira, obrigado pela ajuda.

Link to comment
Share on other sites


Como ficou:


**************************
Function Whatsapp( cPara )
**************************
  Local oShell,wCodCli,lSair,lOk
  If  !IsInternet()
      MsgInfo("Necessário Uma Conexão com Internet !"+CRLF+"Operação cancelada")
      Return(.f.)
  Endif
  wCodCli:=alltrim(right(cpara,5))
  Select cli
  cli->(OrdSetFocus("codigo"))
  seek wcodcli
  lOk:=found()
  Select SRV
  if !lok
     ? "Erro! cliente não encontrado on cadastro!"
     return(.f.)
  endif
  cPara:=alltrim(CLI->FONE_MOVEL)
  cNome:=alltrim(CLI->NOME)
  CursorWait()
  nSegs:=val(GetPvProfString("WhatsApp","SecWaitPage","0",SysArq))
  cMens:=GetPvProfString("WhatsApp","MsgPrinting"    ," ",SysArq)
  cSair:=GetPvProfString("WhatsApp","FechaNavegador" ," ",SysArq)
  If empty(nSegs)
     nSegs:=10 // 10 segundos
     WritePProString( "WhatsApp","SecWaitPage","10",SysArq )
  Endif
  If empty(cMens)
     cMens:="Avisamos que O SEU APARELHO ja esta disponivel! Voce ja pode vir retira-lo."
     WritePProString( "WhatsApp","MsgPrinting",cMens,SysArq )
  Endif
  If empty(cSair)
     cSair:="S"
     WritePProString( "WhatsApp","FechaNavegador","S",SysArq )
  Endif
  cPara:=AjustaFone( cPara )
  If Empty( cPara )
     MsgInfo("Número do telefone de "+cNome+" inválido, verifique!")
     return(.f.)
  endif
  cHora:=Time()
  nHora:=val(substr(cHora,1,2)+substr(cHora,4,2))
  cHora:=iif(nHora>=0000 .and. nHora <=1200 ,"Bom Dia, " , ""   )
  cHora:=iif(nHora>=1201 .and. nHora <=1800 ,"Boa Tarde, ",cHora)
  cHora:=iif(nHora>=1801 .and. nHora <=2359 ,"Boa Noite, ",cHora)
  cCabc:= cHora+"A "+wNomeEmpresa+" tem um recado para voce!"
  oShell:= CreateObject( "WScript.Shell" )
  oShell:run("https://web.whatsapp.com/send?phone="+cPara)
  WaitSeconds(nSegs)
  oShell:sendkeys("*"+cCabc+"*")                            ; WaitSeconds( 3 )   ; oShell:SendKeys("~") ; WaitSeconds( 1 )
  oShell:sendkeys("_"+cMens+"_")                            ; WaitSeconds( 3 )   ; oShell:SendKeys("~") ; WaitSeconds( 1 )
  oShell:sendkeys("*Nosso contato: "+wFoneEmpresa+"*")      ; WaitSeconds( 3 )   ; oShell:SendKeys("~") ; WaitSeconds( 3 )
  If cSair="S"
     oShell:SendKeys("%{F4}")  // ALT+F4 fecha o navegador, mas deixar aberto fica mais rápido....
  Endif
  CursorArrow()
  Return nil

*****************************
FUNCTION AjustaFone( xFone )
*****************************
  Local i,cLetra,cFone:=""
  For i=1 to len(xFone)
      cLetra:=Substr(xFone,i,1)
      cFone+=iif(cLetra="0","0",iif( val(cletra)>0,cLetra,""))
  Next
  If Substr(cFone,1,2)#"55"
     cFone:="55"+cFone
  Endif
  cFone:=alltrim(cFone)
  If len( cFone ) # 13
     cFone:=" "
  endif
  Return( cFone )

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...