User interface AutoIt:如何在浏览器的输入字段中写入?

User interface AutoIt:如何在浏览器的输入字段中写入?,user-interface,scripting,autoit,User Interface,Scripting,Autoit,情景: 我登录了一个网站,想让它自动写入一个输入字段 我怎样才能做到这一点呢?试试这样的方法 #include<IE.au3> $sUsername = "Username" $sPassword = "Password" $sUrl = "https://yoururl.com" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($

情景:

我登录了一个网站,想让它自动写入一个输入字段


我怎样才能做到这一点呢?

试试这样的方法

   #include<IE.au3>
$sUsername = "Username"
$sPassword = "Password"
$sUrl = "https://yoururl.com"
$oIE = _IECreate($sUrl, 0, 1, 0, 1)
Sleep(2000)
$oHWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($oHWND, "", @SW_MAXIMIZE)
$oForm = _IEFormGetCollection($oIE, 0)
$oUsername = _IEFormElementGetObjByName($oForm, 'login') ; change name !
$oPassword = _IEFormElementGetObjByName($oForm, "password") ; change name !
_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEFormSubmit($oForm)
#包括
$sUsername=“用户名”
$sPassword=“密码”
$sUrl=”https://yoururl.com"
$oIE=\u IECreate($sUrl,0,1,0,1)
睡眠(2000年)
$oHWND=_IEPropertyGet($oIE,“hwnd”)
WinSetState($oHWND,“,@SW_最大化)
$oForm=\u IEFormGetCollection($oIE,0)
$userName=\u IEFormElementGetObjByName($oForm,'login');改名!
$oPassword=_IEFormElementGetObjByName($oForm,“password”);改名!
_IEFormElementSetValue($UserName,$sUsername)
_IEFormElementSetValue($oPassword,$sPassword)
_IEFormSubmit($oForm)

firefox也有一个UDF FF.au3,但如果您只需要在PC上使用该脚本,我会使用greasemonkey。

为什么要使用Autoit。如果你正在使用IE,那么你可以使用IE对象进行自动化。搜索输入字段的某些特定和独特的内容,并在此基础上构建。。。i、 e.在字段附近的某个位置使用一种独特的颜色,您可以使用该颜色来确定单击字段的方向。它不需要在球场上,它可以离球场很远,但只要球场的偏移量保持不变,这是一个可行的选择。不过,上面的评论是一个更好的主意。我正在使用您的优秀代码的改编,但我必须向文件中添加#requireadmin,否则它在尝试执行$oIE=_IECreate($sUrl,0,1,0,1)时崩溃。您知道我为什么以及如何防止这种情况发生吗?请看这里: