How can I focus and autofill a text field in Autohotkey?

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!