1

I'm attempting to write a script to automatically fill a web-field with the current date using an AutoHotkey script. However, I'm not sure how to focus a specific field by its name or id.

My current hacky workaround is to use Send, {Tab 84} to scroll to the specific field, type the date with Send, 6/28/2017, and submit the field manually. While the script works most of the time, it's blatantly apparent there are better methods.

How can I focus autofill specific text-field on a webpage using an AutoHotkey script?

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
  • If the specific field doesn't change its position on the webpage, you can use the Click or the ControlClick command. A better choise would be ControlSend or ControlFocus, but I doubt that Autohotkey could recognize any edit control on a webpage. – user3419297 Jun 28 '17 at 19:39
  • Found a possible (unanswered) duplicate: [Find and fill an input field with AutoHotKey](https://stackoverflow.com/q/30102439/3357935) – Stevoisiak Aug 25 '17 at 16:09

1 Answers1

0

An IE COM object should do the trick, as long as you're comfortable navigating the DOM with some JS of your own.

Here's an example:

F3::
wb := ComObjCreate("InternetExplorer.Application") ; Create a IE instance
wb.Visible := True
wb.Navigate("http://google.com")
Sleep, 5000
SendInput, This is test.{Enter}
Sleep, 5000
wb.document.getElementById("lst-ib").value := "This is another test."
wb.document.getElementById("_fZl").click()
return
David Metcalfe
  • 2,237
  • 1
  • 31
  • 44