问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/44810476/how-can-i-focus-and-autofill-a-text-field-in-autohotkey