简体   繁体   English

自动填充用户名和密码并通过自动验证提交的脚本

[英]Autoit Script for populating username and password and submit by validating them automatically

I don't have any idea about AutoIT Scripting, I have one AutoIT Script which will run automatically by clicking one button in my tool. 我对AutoIT脚本一无所知,我有一个AutoIT脚本,可通过单击工具中的一个按钮来自动运行。 With this one webpage will be opened and we need to enter username and password and by submitting it will login to the account. 随即打开一个网页,我们需要输入用户名和密码,提交后将登录到该帐户。 But here I have a task to automate the process of entering the Username and Password and clicking submit button. 但是在这里,我有一个任务可以使输入用户名和密码并单击提交按钮的过程自动化。 I need to read the credentials from the tool and end the process automatically. 我需要从该工具中读取凭据,然后自动结束该过程。

I was Successful in reading credentials from tool but I am facing issue in auto submitting the form. 我成功地从工具中读取了凭据,但是在自动提交表单时遇到了问题。

Now when the webpage is opening the username and password are populating automatically, Please help me to click on the submit button automatically by validating the username and Password field in AutoIT Scripting. 现在,当打开网页时,用户名和密码会自动填充,请通过验证AutoIT脚本中的用户名和密码字段来帮助我自动单击“提交”按钮。

Below is the code I have. 下面是我的代码。 Please suggest syntax to aut submitting this form by validating username and password fields. 请建议通过验证用户名和密码字段来自动提交此表单的语法。

    ; ------------------
; Handle login here! ; CHANGE_ME
; ------------------
Local $o_form = _IEFormGetObjByName ($oIE, "loginData")

Local $o_user = _IEFormElementGetObjByName ($o_form, "j_username")
;Send("{TAB}")
Local $o_password = _IEFormElementGetObjByName ($o_form, "j_password")
;Send("{TAB}")
Local $o_signin = _IEFormElementGetObjByName ($o_form, "submit")
;Send("{ENTER}")

; Set field values and submit the form
_IEFormElementSetValue ($o_user, $TargetUsername)
_IEFormElementSetValue ($o_password, $TargetPassword)
_IEAction ($o_signin, "Click")

Try this piece of code and just change the values. 尝试这段代码,然后更改值。

#include<IE.au3>
$sUsername = "Username"
$sPassword = "Password"
$sUrl = "http://www5.comunio.de/"
$oIE = _IECreate($sUrl, 0, 1, 0, 1)
Sleep(2000)
$oHWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($oHWND, "", @SW_MAXIMIZE)
$oForm = _IEFormGetCollection($oIE, 0)
$oUsername = _IEFormElementGetObjByName($oForm, 'ID_LOGON_UserNameText')
$oPassword = _IEFormElementGetObjByName($oForm, "ID_LOGON_PasswordText")
_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEFormSubmit($oForm)

Usually javascript is doing the validation. 通常,JavaScript会执行验证。 In order to trigger it you can use .focus , .click etc. 为了触发它,你可以使用.focus.click等。

You should check if .click is already triggering .focus . 你应该检查.click已触发.focus

; ------------------
; Handle login here! ; CHANGE_ME
; ------------------
Local $o_form = _IEFormGetObjByName ($oIE, "loginData")

Local $o_user = _IEFormElementGetObjByName ($o_form, "j_username")
Local $o_password = _IEFormElementGetObjByName ($o_form, "j_password")
Local $o_signin = _IEFormElementGetObjByName ($o_form, "submit")

; Set field values and submit the form
_IEFormElementSetValue ($o_user, $TargetUsername)
_IEFormElementSetValue ($o_password, $TargetPassword)

$o_user.click
$o_user.focus

$o_password.click
$o_password.focus

$o_signin.focus
$o_signin.click

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM