Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/12/2017, 06:06
sacris1
 
Fecha de Ingreso: julio-2008
Mensajes: 155
Antigüedad: 15 años, 9 meses
Puntos: 1
Acceder pestaña del navegador csharp

Hola a todos,
Primero de todo daros las gracias por vuestra labor de ayudar a todo aquel que necesita ayuda sobre algun problema o duda relacionado con el inmenso mundo de la informática.

Necesito hacer un programa en Csharp o Visual basic para rellenar unos campos de una página web.
La página web tiene un login y luego una serie de campos unos 15.

Tengo un programa ya hecho pero me funciona con aplicaciones de escritorio.
Utilizando la libreria del sistema user32.


[System.Runtime.InteropServices.DllImport("user32.d ll")]
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);

[System.Runtime.InteropServices.DllImport("user32.d ll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); //ShowWindow needs an IntPtr

[System.Runtime.InteropServices.DllImport("user32.d ll")]
internal static extern IntPtr FindWindowByCaption(IntPtr hWnd, String NomFinestra); //ShowWindow needs an IntPtr

[System.Runtime.InteropServices.DllImport("user32.d ll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);



private static void FocusProcess2()
{

IntPtr windowPtr = FindWindow(null, "Nueva carpeta");

ShowWindow(windowPtr, 1);
SetForegroundWindow(windowPtr); //set to topmost
System.Threading.Thread.Sleep(1);
SendKeys.SendWait("{TAB}");

SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{TAB}");

SendKeys.SendWait("A");
SendKeys.SendWait("{ENTER}");

}


¿Alguna idea?
El usuario utiliza chrome pero puede utilizar firefox.
No me pregunteis porqué pero el usuario siempre tiene mil pestañas abiertas, pues no me queda otra que recorrer toas las pestañas hasta encontrar la correcta. Almenos el nombre de la pestaña siempre es el mismo.

Gracias.
Saludos.