getElementbyID("LoginSubmit").submit() not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cleanmedia1000
Posts: 5
Joined: 03 Jul 2020, 04:07

getElementbyID("LoginSubmit").submit() not working

Post by cleanmedia1000 » 21 Feb 2021, 20:15

My script to open a login webpage, fill in the username, then fill in the password, then click the submit button, works fine up for the first two parts, but when it comes to clicking the submit button, nothing happens, and I get an Error: 0x80020006 - Unknown Name pointing at the line with "submit()" This is using AHK 1.1.33.02 on Windows 10 Pro Version 1909 ... Thank for any thoughts. I have searched to see about using .submit() but haven't found anything.

Code: Select all

^0::
Web_Browser := ComObjCreate("InternetExplorer.Application")
Web_Browser.Visible := True
Web_Browser.Navigate("https auth.edgenuity.com /Login/Login/Student")  Broken Link for safety

while Web_Browser.busy
{
sleep 500
}
sleep 1000

UsernameInput := Web_Browser.document.getElementbyID("LoginUsername")
UsernameInput.value := "xxxxxxxxxxx"   ; I removed the actual username for this example.

PasswordInput := Web_Browser.document.getElementbyID("LoginPassword")
PasswordInput.value := "yyyyyyyyyy"

sleep 4000
Web_Browser.document.getElementbyID("LoginSubmit").submit( )

return
[Mod edit: [code][/code] tags added.]
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: getElementbyID("LoginSubmit").submit() not working

Post by gregster » 21 Feb 2021, 20:48

Try

Code: Select all

Web_Browser.document.getElementById("LoginSubmit").click()

Btw, this dark blue font color you use can be hard to read for forum users with dark forum themes. I would recommend to mostly keep the standard font colors provided by the forum - they should adjust automatically in the different forum themes - and to keep other colors for special highlighting. Instead I'd recommend to add [code][/code] tags around your code (5th button from the left in the full editor). Thank you!
cleanmedia1000
Posts: 5
Joined: 03 Jul 2020, 04:07

Re: getElementbyID("LoginSubmit").submit() not working

Post by cleanmedia1000 » 22 Feb 2021, 09:17

That works. Thanks. So I have looked for the documentation for what I am doing here,
but so far am looking at the wrong things. What is and where is the applicable documentation
for using the AHK code for syntax of events, functions etc like I am doing?

Thanks as well for the heads up about the font colors.
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: getElementbyID("LoginSubmit").submit() not working

Post by gregster » 22 Feb 2021, 09:34

Since you are using the COM interface of the Internet Explorer, the general documentation is rather available at Microsoft: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752084(v=vs.85)

Of course, there are countless examples about using IE COM via AHK on these forums, but things like getElementById() and click() are more DOM-specific methods (html/javascript-related) which can be used via the IE COM interface. See, for example, https://www.w3schools.com/jsref/met_document_getelementbyid.asp and https://www.w3schools.com/jsref/met_html_click.asp .
cleanmedia1000
Posts: 5
Joined: 03 Jul 2020, 04:07

Re: getElementbyID("LoginSubmit").submit() not working

Post by cleanmedia1000 » 22 Feb 2021, 09:35

Very helpful, gregster.
Post Reply

Return to “Ask for Help (v1)”