如何在Autohotkey中聚焦和自动填充文本字段? [英] How can I focus and autofill a text field in Autohotkey?

查看:442
本文介绍了如何在Autohotkey中聚焦和自动填充文本字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个脚本,以使用AutoHotkey脚本自动用当前日期填充Web字段.但是,我不确定如何通过nameid聚焦特定字段.

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.

我当前的hacky解决方法是使用Send, {Tab 84}滚动到特定字段,使用Send, 6/28/2017键入日期,然后手动提交该字段.尽管该脚本大部分时间都可以运行,但显然可以找到更好的方法.

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.

如何使用AutoHotkey脚本在网页上自动填充特定的文本字段?

推荐答案

只要您愿意使用自己的一些JS来浏览DOM,IE COM对象就可以解决问题.

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

这是一个例子:

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

这篇关于如何在Autohotkey中聚焦和自动填充文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆