Dependiendo de la resolución habrá que cambiar las líneas que pulsan en la caja de texto para buscar algo en Google y la que pulsa en el primer enlace del resultado de la búsqueda.
Pulsar en la caja de texto para realizar la búsqueda:
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(419,284)
Pulsar en el primer enlace del resultado de la búsqueda:
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(419,284)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# Importar función para hacer clic $MouseEventSig=@' [DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)] public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo); '@ $MouseEvent = Add-Type -memberDefinition $MouseEventSig -name "MouseEventWinApi" -passThru Add-Type -AssemblyName System.Windows.Forms Start-Sleep -Seconds 5 # Arrancar Google Chrome $url='https://www.google.es' Start-Process chrome.exe $url # Esperar hasta cargar Google Chrome Start-Sleep -Seconds 5 # Escribir una palabra y pulsar ENTER [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(416,468) [System.Windows.Forms.SendKeys]::SendWait("jesusninoc") [System.Windows.Forms.SendKeys]::SendWait("{ENTER}") Start-Sleep -Seconds 5 # Pulsar en el primer enlace de los resultados [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(419,284) $MouseEvent::mouse_event(0x00000002, 0, 0, 0, 0) $MouseEvent::mouse_event(0x00000004, 0, 0, 0, 0) |