Skip to content

Instantly share code, notes, and snippets.

@atimermann
Created August 27, 2015 22:53
Show Gist options
  • Save atimermann/b25350b0293654a1ed0a to your computer and use it in GitHub Desktop.
Save atimermann/b25350b0293654a1ed0a to your computer and use it in GitHub Desktop.
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.12.0
Author: André Timermann
Script Function:
Automação Download de Arquivo Siscarga
#ce ----------------------------------------------------------------------------
;AutoItSetOption("MustDeclareVars", 1)
;REMOVER REMOVER REMOVER REMOVER REMOVER REMOVER REMOVER
Func logWrite($msg)
ConsoleWrite($msg & @LF);
EndFunc
;REMOVER REMOVER REMOVER REMOVER REMOVER REMOVER REMOVER
#AutoIt3Wrapper_UseX64=Y
#include <IE.au3>
#include "../../vendor/UIAWrappers.au3"
; ===============================================================================================================================
; MAIN 01
; ===============================================================================================================================
Func _003main($taskId, $WorkerId, $data)
logWrite("Iniciando Automação Siscarga Argos");
; ==================================================================================
; 001 - Inicia Internet Explorer com Certificado
; ==================================================================================
logWrite("Carregando Internet Explorer");
; Carrega Internet Explorer (Não aguarda execução, pois abre janela do certificado)
Local $oIE = _IECreate("https://www4c.receita.fazenda.gov.br/carga-web", 0, 1, 0)
; Aguarda Carregar Janela para Seleção de Certificado
logWrite("Carregando Certificado");
WinWait("Windows Security", "", 30);
; Carrega Proprietário do Certificado para salva no INFO
Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Windows Internet Explorer;controltype:=UIA_PaneControlTypeId;class:=Alternate Modal Top Most", $TreeScope_Children)
Local $oP1=_UIA_getObjectByFindAll($oP0, "Title:=Windows Security", $TreeScope_Children)
Local $oP2=_UIA_getObjectByFindAll($oP1, "controltype:=UIA_ListControlTypeId;class:=Selector", $TreeScope_Children)
Local $oP3=_UIA_getObjectByFindAll($oP2, "controltype:=UIA_ListItemControlTypeId;class:=CredProvUserTile", $TreeScope_Children)
Local $oP4=_UIA_getObjectByFindAll($oP3, "controltype:=UIA_TextControlTypeId;class:=Element;automationid:=CredProvLargeText", $TreeScope_Children)
if isobj($oP4) Then
local $nome = _UIA_getPropertyValue($oP4, $UIA_NamePropertyId)
logWrite("Usando certificado: " & $nome);
EndIf
;; Seleciona OK no Certificado
ControlClick("Windows Security", "OK", "[CLASS:Button; INSTANCE:2]");
; OK
logWrite('OK');
EndFunc
_003main(1,1,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment