我是JavaScript和autohotkey programmation的新手。我正在嘗試登錄網站,但到目前爲止我無法正確提交表單。JavaScript:使用autohotkey登錄網站
這裏是頁面的HTML:
<form ng-show="!maintenanceCritique" class="form ng-pristine ng-valid-pattern ng-valid-maxlength ng-valid ng-valid-required" name="formMobile" ng-submit="login(formMobile)" novalidate="" touch-submit="">
<div style="padding-top:30px;padding-left:20px;padding-right:20px">
<span> Code permanent</span><br>
<input style="width:100%" name="codePermanent" ng-model="user.codePermanent" ng-pattern="/^[A-Za-z]{4}(0[1-9]|[12][0-9]|3[01]|6[3-9]|[78][0-9]|9[0-3]|99)([0,5][1-9]|[1,6][012]|13|63)[0-9]{4}$/" maxlength="12" tabindex="1" placeholder="(ex. : ABDC12034566)" autofocus="" required="" class="ng-pristine ng-valid-pattern ng-valid-maxlength ng-not-empty ng-valid ng-valid-required ng-touched">
<br><br>
<span> NIP</span><br>
<input style="width:100%" type="password" name="password" ng-model="user.password" ng-pattern="/^[0-9]{5}$/" maxlength="5" tabindex="2" placeholder="(ex. : 12345)" required="" class="ng-pristine ng-valid-pattern ng-valid-maxlength ng-not-empty ng-valid ng-valid-required ng-touched">
<div>
<!-- ngIf: formMobile.codePermanent.$error.required && formMobile.password.$error.required && submitted -->
<!-- ngIf: err -->
</div>
<br>
<div style="text-align:right">
<button class="btn btn-default btn-inverse btn-lg btn-login text-uppercase" type="submit" click="submitted=true" tabindex="3">
<span style="height:60%;width:140px;text-transform:none;font-family:'Conv_Dosis',arial,sans-serif; font-size:100%">Connexion</span>
</button>
</div>
</form>
</div>
這裏是我的代碼:
WB := ComObjCreate("InternetExplorer.Application")
WB.Visible := True
WB.Navigate(URL)
loop
If !WB.busy
break
sleep 1000
WB.document.getElementsByName("codePermanent")[0].focus()
WB.document.getElementsByName("codePermanent")[0].value := "username"
sleep 1000
WB.document.getElementsByName("password")[0].focus()
WB.document.getElementsByName("password")[0].value := "password"
form := WB.document.getElementsByName("form")[0]
form.method := "post"
form.submit()
我已經嘗試過了,並沒有記錄我,可惜你 –
可以嘗試通過passint通過jQuery點擊它,它通過地址欄。看看它是否有效:'wb.Navigate(JavaScript:$('input [type = submit]')。click())' – GroggyOtter