Jump to content

Recommended Posts

Posted (edited)

Tried with following codes from example given in the forum (if ie non hidden, code works fine), need to save the cert file in hidden or given location.

 

Global $oIE = _IECreate("http://testca", 0, 0, 1, 1)
    _IENavigate($oIE, "http://testca/certsrv/certrqxt.asp")
    _IELoadWait($oIE)

    $hnd = WinGetHandle($oIE)
    $act = WinActivate($hnd, "")
    _WinAPI_SetFocus($act)
    Global $csrfile = ("C:\Users\slingaya\Downloads\test.txt")

    Local $hFileOpen = FileOpen($csrfile, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead1 = FileRead($hFileOpen)


    Sleep(1000)
    Global $oInputs1 = _IEGetObjById($oIE, "locTaRequest")
    _IEAction($oInputs1, "click")
    Sleep(1000)
    _IEFormElementSetValue($oInputs1, $sFileRead1)

    ; Select Certificate Template:
    Sleep(1000)
    $certtemplate1 = _IEGetObjById($oIE, "lbCertTemplateID")
    _IEAction($certtemplate1, "click")
    _IEFormElementOptionSelect($certtemplate1, "Web Server", 1, "byText")

    ;Formsubmit
    Sleep(2000)
    $submit1 = _IEGetObjById($oIE, "btnSubmit")
    _IEAction($submit1, "click")

    Sleep(2000)

    $DRencodedclick = _IEGetObjById($oIE, "rbB64Enc")
    _IEAction($DRencodedclick, "click")

    ;================================================
    Sleep(2000)
    ;==================================================================
    $downcertclick = _IEGetObjById($oIE, "locPageFont")
    $downcertclick1 = _IEGetObjById($downcertclick, "UIForm")
    $downcertclick2 = _IEGetObjById($downcertclick1, "locDwnld2Font")
    $downcertclick3 = _IEGetObjById($downcertclick2, "locDownloadCert2")
    _IEAction($downcertclick3, "click")

    Global $CSRfilesavelocation = ("C:\Users\cyborg\Downloads")

    Sleep(2000)
    $hIE2 = _IEPropertyGet($oIE, "hwnd")

    Sleep(2000)

    Do
        If WinActive("[Class:IEFrame]") Then
            Local $hIE = WinGetHandle("[Class:IEFrame]")
            Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
            Local $aPos = ControlGetPos($hIE, "", $hCtrl)
            Local $aWinPos = WinGetPos($hIE)
            If ControlCommand($hIE, "", $hCtrl, "IsVisible") And $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page.
                ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30)
                Sleep(500)
                ControlSend($hIE, "", $hCtrl, "{down}{down}{enter}")
            EndIf
        EndIf
        Sleep(100)
    Until WinExists("Save As")

    WinActivate("Save As")
    Send("!n")
    Sleep(1000) ; without this, then next send often gets truncated.
    Send($CSRfilesavelocation & "\certfic.cer")
    Send("!s")

    While WinExists("Save As")
        Sleep(100)
    WEnd

Edited by Cyborg5000

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...