SteveMann Posted June 7, 2023 Posted June 7, 2023 I use the Alexa Routine Node in Node-Red, and it is great, but the daily authentication of my Amazon account at “192.168.1.56:3456” in my browser is getting tedious. I would like to find a way to automate this. I thought about Auto Hot Key on my PC, but learning that is a whole new challenge to someone who barely understands YAML. Basically, I need to open “192.168.1.56:3456” in my browser. I will either be prompted to enter my Amazon password, or get a 404 error. Both are normal. If I get a 404 error then I don't need to authenticate my Amazon account and I can close the browser. If I get a prompt for my password, I enter it then close my browser. So, is this something I could do using Autoit?
Skeletor Posted June 7, 2023 Posted June 7, 2023 Test this out? #include <Constants.au3> #include <IE.au3> ; Open Internet Explorer Local $oIE = _IECreate() ; Navigate to the URL _IENavigate($oIE, "http://192.168.1.56:3456") ; Wait for the page to load _IELoadWait($oIE) ; Check if a password prompt is displayed If _IEFormElementExists($oIE, "password_field_name") Then ; Enter your Amazon password Local $oPasswordField = _IEGetObjByName($oIE, "password_field_name") _IEFormElementSetValue($oPasswordField, "your_password") ; Submit the form _IEFormSubmit($oPasswordField.form) Sleep(2000) ; Wait for the form to submit ; Close the browser _IEQuit($oIE) ElseIf _IEPropertyGet($oIE, "readyState") = "404" Then ; Close the browser _IEQuit($oIE) EndIf Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
SteveMann Posted June 7, 2023 Author Posted June 7, 2023 Many thanks, this gives me a lot to work with. For some reason, Autoit is opening an old version of IE that won't open the URL. When I enter "ie" in my search bar, I get MS Edge browser, which does open the URL. Any suggestions of how to open MS Edge or make the old IE work would be appreciated. I also get an Autoit error: "if _IEFormElementExists()", error, unknown function name. I can't find that function in the help pages, have I spelled it wrong? -------------------------------------------
OJBakker Posted June 7, 2023 Posted June 7, 2023 Just create a new shortcut, enter the webadres as the target and give the shortcut a name. When started this will open your default webbrowser with the specified webadres. If you want to use an other browser then make a shortcut to that browser and add the webadres as parameter in the shortcut after the browserprogram.
mistersquirrle Posted June 7, 2023 Posted June 7, 2023 Another thing is that some sites will accept a format like: http://username:password@192.168.1.56:3456, so you can try that, though I have no idea what the page looks like or how it's prompting the password. I think that usually that format only works for sites that prompt user/pass with a browser alert/dialog box, and not a form. That function (_IEFormElementExists) does not exist in AutoIt, it's likely a UDF they're using or made. However to make the code work, it's just a couple changes to do (mostly) the same thing: #include <Constants.au3> #include <IE.au3> ; Open Internet Explorer Global $oIE = _IECreate() ; Navigate to the URL _IENavigate($oIE, "http://192.168.1.56:3456") ; Wait for the page to load _IELoadWait($oIE) Global $oPasswordField = _IEGetObjByName($oIE, "password_field_name") ; Check if a password prompt is displayed If Not @error Then _IEFormElementSetValue($oPasswordField, "your_password") ; Submit the form _IEFormSubmit($oPasswordField) Sleep(2000) ; Wait for the form to submit ; Close the browser _IEQuit($oIE) ElseIf _IEPropertyGet($oIE, "readyState") = "404" Then ; Close the browser _IEQuit($oIE) EndIf Just _IEGetObjByName is enough to check if it 'exists', since it'll throw an @error if it doesn't We ought not to misbehave, but we should look as though we could.
SteveMann Posted June 7, 2023 Author Posted June 7, 2023 1 hour ago, mistersquirrle said: it's just a couple changes to do (mostly) the same thing: Thanks for the correction. There are no errors from Autoit, but the response from the browser is exactly the same: "Can't reach this page". And as before if I enter the URL into any browser manually, it opens as expected.
mistersquirrle Posted June 7, 2023 Posted June 7, 2023 You may want to check your Internet Options, specifically Connections -> LAN Settings: Make sure that there's nothing setup in there, or that it's set up correctly. If you manually enter it in an Internet Explorer window, does it work or fail? What's under the 'More Info' button on the page? You could also look into using the WebDriver UDF to do it through a different browser: We ought not to misbehave, but we should look as though we could.
SteveMann Posted June 8, 2023 Author Posted June 8, 2023 3 hours ago, mistersquirrle said: If you manually enter it in an Internet Explorer window, does it work or fail? It works just fine as expected. The "more info" just gives the usual "check your connections", etc.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now