zekasan Posted May 17, 2018 Report Share Posted May 17, 2018 Bom dia, alguém pode me ajudar??? Como fico sabendo se a janela aberta na rotina CreateObject("InternetExplorer.Application"), está aberta??? oOle:= CreateObject("InternetExplorer.Application") oOle:Visible := .t. oOle:ToolBar := .f. oOle:StatusBar := .f. oOle:MenuBar := .f. oOle:Navigate2("https://www.sefaz.rs.gov.br/NFE/NFE-CCC.aspx") hWnd:=oOle:hWnd ShowWindow(hWnd, 1 ) BringWindowToTop(hWnd) While oOle:Busy syswait(.5) End * cCopiar("60157377000504") try oOle1 := oOle:Document() oOle1:getElementById("ctl00_cphConteudo_cmbUF"):value := "35" // 35-> SP oOle1:getElementById("ctl00_cphConteudo_cmbUF"):Focus() oOle1:getElementById("ctl00_cphConteudo_cmbUF"):Click() oOle1:getElementById("tbxCNPJContrib"):value := QUAL_CNPJ catch end do while JANELA_ABERTA???? syswait(??) enddo GRATO Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 17, 2018 Report Share Posted May 17, 2018 Não entendi muito bem, mas veja se ajuda. https://imgur.com/dkfQicV #Include "FiveWin.ch" #Include "hbcompat.ch" Function Main() LOCAL cRet cRet := MsgRun( "Verificando a Sefaz.", ; "Por Favor, Espere!" , ; { || STRTRAN( PegaSefaz(), '*',';' ) } ) RETURN NIL Function PegaSefaz() Local OOLE, CDIA, CMES, CANO, CDATA, CHORA, QUAL_CNPJ Local cRet := "", cPagina := "" Local cTexto := "Local time in Brasilia" IF ( oOle := Cria_OLE( "InternetExplorer.Application", , .T. ) ) == NIL RETURN( .F. ) ENDIF QUAL_CNPJ := "60157377000504" oOle:Visible := .T. oOle:ToolBar := .F. oOle:StatusBar := .F. oOle:MenuBar := .F. oOle:Navigate("https://www.sefaz.rs.gov.br/NFE/NFE-CCC.aspx") WHILE oOle:ReadyState() != 4 // Aguarda página ser carregada, mesmo q não seja visualizado no Navegador (opão Visible := F ou T) SysWait( .5 ) ENDDO try oOle := oOle:Document() oOle:getElementById("ctl00_cphConteudo_cmbUF"):value := "35" // 35-> SP oOle:getElementById("ctl00_cphConteudo_cmbUF"):Focus() oOle:getElementById("ctl00_cphConteudo_cmbUF"):Click() oOle:getElementById("tbxCNPJContrib"):value := QUAL_CNPJ catch end Return( cRet ) //------------------------------------------------------------------------------ FUNCTION Cria_OLE(cObj_OLE, cMsg, lGetActiveObj) /* Cria objeto Ole */ LOCAL oObj_OLE := NIL cMsg:='Erro ao Tentar Carregar Pagina...Tente Novamente' lGetActiveObj:=.F. IF lGetActiveObj TRY oObj_OLE := GetActiveObject( cObj_OLE ) CATCH TRY oObj_OLE := CREATEOBJECT(cObj_OLE) CATCH Alert(cMsg) RETURN oObj_OLE END END ELSE TRY oObj_OLE := CREATEOBJECT(cObj_OLE) CATCH Alert( cMsg ) RETURN oObj_OLE END ENDIF RETURN oObj_OLE // FIM Quote Link to comment Share on other sites More sharing options...
zekasan Posted May 17, 2018 Author Report Share Posted May 17, 2018 Preciso que fique em um loop após ser aberta até a janela ser fechada, para dar prosseguimento a uma outra rotina, essa outra rotina será executada assim que esta janela aberta for fechada. Quote Link to comment Share on other sites More sharing options...
zekasan Posted May 17, 2018 Author Report Share Posted May 17, 2018 COLOQUEI O SEGUINTE do whil .t. try CONDICAO:=oOle:readystate catch exit end syswait(.5) enddo kapiaba 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.