Visual Basic - acceso con usuario y contraseña a servidor https con vba excel

Life is soft - evento anual de software empresarial
   
Vista:

acceso con usuario y contraseña a servidor https con vba excel

Publicado por Isidro gonzalez (2 intervenciones) el 18/12/2013 12:01:44
Buenos días, os cuento mi problema:
Estoy intentando programar en visual basic el acceso a una página https y autenticarme con usuario y contraseña, el caso es que cuando en el programa ejecuto paso a paso y llega a la instrucción de navegación, sale la pantalla de seguridad de windows con el usuario y contraseña, pero el programa de visual se queda parado y no sigue ejecutando las siguientes instrucciones de "búsqueda y rellenado del usuario y contraseña" , es como si esperase que los datos se introdujesen vía INTERFAZ DE USUARIO. Muchas gracias


Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function SendMessageLONG Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_SETTEXT = &HC
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_EXTENDEDKEY = &H1

Private Sub CommandButton2_Click()
Dim link_name As String
Dim Progress As Integer

link_name = Sheets("Hoja1").Range("D2")
Call Sheets("Hoja1").WebBrowser1.Navigate(link_name)
----AQUI SE QUEDA PARADO EL PROGRAMA Y EN LA PANTALLA DEL EXPLORER SALE LA VENTANA DE SEGURIDAD DE WINDOWS---COMO SI ESPERASE QUE SE INTRODUJERAN LOS DATOS VÍA USUARIO
If Progress = 100 Then 'cuando carga la pagina al 100 % empieza el proceso

Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function SendMessageLONG Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_SETTEXT = &HC
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_EXTENDEDKEY = &H1

End If

End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

acceso con usuario y contraseña a servidor https con vba excel

Publicado por Isidro gonzalez (2 intervenciones) el 18/12/2013 12:20:06
Perdonar, me he pasado con el copy paste, el programa que he utilizado es
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function SendMessageLONG Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_SETTEXT = &HC
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_EXTENDEDKEY = &H1


Sub Pulsar_Tecla(ByVal Tecla As Long)
Call keybd_event(Tecla, 0, 0, 0)
Call keybd_event(Tecla, 0, KEYEVENTF_KEYUP, 0)
End Sub


Private Sub CommandButton2_Click()
Dim link_name As String
Dim Progress As Integer

link_name = Sheets("Hoja1").Range("D2") %AQUI LE METO LA DIRECCION HTTPS%
Call Sheets("Hoja1").WebBrowser1.Navigate(link_name)

---SE QUEDA PARADO AQUI-----------------------------------
If Progress = 100 Then 'cuando carga la pagina al 100 % empieza el proceso
Dim a As Long, b As Long, c As Long, d As Long, f As Long, g As Long
a = FindWindow("#32770", vbNullString) 'la ventana padre
b = FindWindowEx(a, 0&, "syscredential", vbNullString) 'el marco oculto
c = FindWindowEx(b, 0&, "comboboxex32", vbNullString) 'el combo padre
d = FindWindowEx(c, 0&, "combobox", vbNullString) 'el combo contenedor
f = FindWindowEx(d, 0&, "edit", vbNullString) 'el textbox del usuario
g = FindWindowEx(b, 0&, "edit", vbNullString) 'el del password
Call SendMessageSTRING(g, WM_SETTEXT, 256, "XXXXXX") 'pones la contraseña
Call SendMessageSTRING(f, WM_SETTEXT, 256, "XXXXXX") 'pones el usuario
Call Pulsar_Tecla(vbKeyReturn) 'para aceptar los datos
End If

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar