Roman Posted December 11, 2013 Posted December 11, 2013 (edited) Hi To avoid the mandatory, monthly login on dyndns.org manually (otherwise one will loose the free dyndns account), I wanted to develop a small script which should run in the background (startup script) and login me every time I start Windows. I tried it with "InetGet" and "InetRead" but never with success. I never got logged in. InetGet("https://username:password@account.dyn.com/...) InetRead("https://username:password@account.dyn.com/...) Has anyone a hint for me how to script this with AutoIt? Kind regards, Roman Edited December 11, 2013 by roman
Xenobiologist Posted December 11, 2013 Posted December 11, 2013 #Region ;************ Includes ************ #Include <String.au3> #include<IE.au3> #EndRegion ;************ Includes ************ $sUsername = "Username" $sPassword = "Password" $sUrl = "https://account.dyn.com/entrance/" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") $html = _IEPropertyGet($oIE, "innerhtml") $user = StringRegExp($html, 'id=login(\d*)_username', 3) ConsoleWrite('!' & $user[0] & @CRLF) $password = StringRegExp($html, 'id=login(\d*)_password', 3) ConsoleWrite('!' & $password[0] & @CRLF) WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 1) $oUsername = _IEFormElementGetObjByName($oForm, 'login' & $user[0] & '_username') $oPassword = _IEFormElementGetObjByName($oForm, 'login' & $password[0] & '_password') _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) ;~ _IEFormSubmit($oForm) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Roman Posted December 12, 2013 Author Posted December 12, 2013 Thank you. I've set the two variables with my personal values, but unfortunately the scripts works not as expected. The last action is opening the IE with the desired adress (and the sleep statement), after that happens nothing more. I've played around with the URL, but without success. Regards.
trancexx Posted December 12, 2013 Posted December 12, 2013 (edited) You can use WinHttp.au3 to exclude IE. It's very simple code using form filling function. That way it can even be run as service monthly active. ...just checkk that you aren't against dyn's rules. Edited December 12, 2013 by trancexx ♡♡♡ . eMyvnE
Xenobiologist Posted December 12, 2013 Posted December 12, 2013 Thank you. I've set the two variables with my personal values, but unfortunately the scripts works not as expected. The last action is opening the IE with the desired adress (and the sleep statement), after that happens nothing more. I've played around with the URL, but without success. Regards. Did you get any errors or did you get the console output? I tested the script and it works for me. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Roman Posted December 13, 2013 Author Posted December 13, 2013 (edited) Yes, I get the following error: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Usersude0994DesktopInetGet.au3" /UserParams +>10:18:19 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0409 Keyboard:00000807 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86)>Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3+>10:18:19 AU3Check ended.rc:0>Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:Usersude0994DesktopInetGet.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to StopC:Usersude0994DesktopInetGet.au3 (13) : ==> Subscript used with non-Array variable.: ConsoleWrite('!' & $user[0] & @CRLF) ConsoleWrite('!' & $user^ ERROR->10:18:22 AutoIT3.exe ended.rc:1>Exit code: 1 Time: 4.184 Edited December 13, 2013 by roman
Xenobiologist Posted December 13, 2013 Posted December 13, 2013 Try to debug. Use ConsoleWrite for the variables. Is $oIE an object? is $html the sourcecode of the site? And so on. Check the error of StringRegExp. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Exit Posted December 13, 2013 Posted December 13, 2013 ; DYNDNS login at boot startup. Place it in autostart. #include <IE.au3> $Account = "?????????" $Password = "??????" Sleep(60000) ; suspend for a minute to allow other startup tasks to use CPU cycles during TCPIP startup Do Until Ping("account.dyn.com") Sleep(20000) ; we are not in a hurry :-) $oIE = _IECreate("https://account.dyn.com/", 0, 0) Sleep(10000) ; we are not in a hurry :-) $object = _IEGetObjByName($oIE, "username") _IEPropertySet($object, "innertext", $Account) $object = _IEGetObjByName($oIE, "password") _IEPropertySet($object, "innertext", $Password) $object = _IEGetObjByName($oIE, "submit") _IEAction($object, "click") Sleep(10000) $object = _IEGetObjById($oIE, "topnav") If StringInStr(_IEPropertyGet($object, "innertext"), $Account) Then TrayTip("DynDNS Login", "successful", 5) Else MsgBox(262144, "Debug " & @ScriptName, "Error during DynDNS Login.", 0) EndIf Sleep(500) _IENavigate($oIE, "https://account.dyn.com/dns/dyndns/") Sleep(500) _IENavigate($oIE, "https://account.dyn.com/entrance/?__logout=1") Sleep(500) _IEQuit($oIE) Sleep(5000) ; Allow traytip to display 5 seconds ; eof App: Au3toCmd UDF: _SingleScript()
AutID Posted December 14, 2013 Posted December 14, 2013 #include "WinHttp.au3" Global $sUser = "name" Global $sPassword = "pass" Local $hOpen = _WinHttpOpen() If @error Then ConsoleWrite("WinHttp open error: " & @error & @LF) Local $hConnect = _WinHttpConnect($hOpen, "account.dyn.com") If @error Then ConsoleWrite("Server conection error: " & @error & @LF) Local $hLogin = _WinHttpSimpleFormFill($hConnect, _ "/entrance/", _ "login94", _ "login94_username", $sUser, _ "login94_password", $sPassword) If @error Then ConsoleWrite("Log in error: " & @error & @LF) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If StringInStr($hLogin, $sUser) Then ConsoleWrite("Succesfully logged in!" & @LF) Else ConsoleWrite("Failed to log in, check the errors" & @LF) EndIf I do not have an account on that site so i can't actually test the above code but it should work. 100% better than an IE solution for what you are looking for if you dont want to display the IE. You can find further informations here: https://iblockify.wordpress.com/
trancexx Posted December 15, 2013 Posted December 15, 2013 It would be more like this:#include "WinHttp.au3" $sUsername = "your_account_name_here" $sPassword = "whatever_the_password" $sUrl = "https://account.dyn.com/entrance/" ; session handle $hOpen = _WinHttpOpen() ; connection handle $hConnect = _WinHttpConnect($hOpen, $sUrl) ; login by filling login form $sRead = _WinHttpSimpleFormFill($hConnect, _ Default, _ ; login page "index:1", _ ; form with index 1 (second form) "name:username", $sUsername, _ "name:password", $sPassword) ; close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; e.g. (you should see your name somewhere here, it'll be "something... <span>Welcome <b>your_account_name_here</b></span> ...something") ConsoleWrite($sRead & @CRLF) ♡♡♡ . eMyvnE
AutID Posted December 16, 2013 Posted December 16, 2013 hmmm, i created an account to see what was wrong. The form's id was changing. I tried using index 1 as well and it failed. Then i created this but it fails again.expandcollapse popup#include "WinHttp.au3" Global $sRead, $sData, $hOpen, $hConnect, $hRequest Global Const $sUsername = "name" Global Const $sPassword = "pass" Global Const $sUrl = "account.dyn.com" Global $form = _FormID() If @error Then ConsoleWrite(@error & @CRLF) _sExit() Else ConsoleWrite($form & @CRLF) EndIf $sRead = _WinHttpSimpleFormFill($hConnect, _ "/entrance/", _ $form, _ "name:username", $sUsername, _ "name:password", $sPassword) If @error Then ConsoleWrite(@error & @CRLF) Else ConsoleWrite($sRead & @CRLF) EndIf _sExit() Func _FormID() $hOpen = _WinHttpOpen() If @error Then SetError(1) $hConnect = _WinHttpConnect($hOpen, $sUrl) If @error Then SetError(2) $hRequest = _WinHttpOpenRequest($hConnect) If @error Then SetError(3) _WinHttpSendRequest($hRequest) If @error Then SetError(4) _WinHttpReceiveResponse($hRequest) If @error Then SetError(5) If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sRead = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sRead WEnd Local $eData = StringRegExp($sData, "form id='(.+?)'", 1) Return String($eData[0]) Else SetError(6) EndIf EndFunc Func _sExit() _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Exit EndFunc There mucst be something tricky on the server's side. https://iblockify.wordpress.com/
trancexx Posted December 16, 2013 Posted December 16, 2013 ^^The code I posted works for sure. Maybe you need newer WinHttp.au3. ♡♡♡ . eMyvnE
AutID Posted December 16, 2013 Posted December 16, 2013 (edited) I had the one you gave me, i guess it was old. With the new version it worked for me too. With the index 1 that points to the form. However this functions won't work with the latest winhttp.au3 Func _FormID() $hOpen = _WinHttpOpen() If @error Then SetError(1) $hConnect = _WinHttpConnect($hOpen, $sUrl) If @error Then SetError(2) $hRequest = _WinHttpOpenRequest($hConnect) If @error Then SetError(3) _WinHttpSendRequest($hRequest) If @error Then SetError(4) _WinHttpReceiveResponse($hRequest) If @error Then SetError(5) If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sRead = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sRead WEnd Local $eData = StringRegExp($sData, "form id='(.+?)'", 1) Return String($eData[0]) Else SetError(6) EndIf EndFunc in case i give the entire url instead of the server like you did in the example. I checked only the _WinHttpSimpleFormFill function and found out some changes. Didn't check the others. Since _FormID() function returns the id of the form then why the old way won't work since the parameters are still the same? ; Parameters ....: $hInternet - Handle returned by _WinHttpConnect() or string variable with form. ; $sActionPage - [optional] path to the page with form or session handle if $hInternet is string (default: "" - empty string; meaning 'default' page on the server in former). ; $sFormId - [optional] Id of the form. Can be name or zero-based index too (read Remarks section). ; $sFieldId1 - [optional] Id of the input. ; $sData1 - [optional] Data to set to coresponding field. ; (...) - [optional] Other pairs of Id/Data. Overall number of fields is 40. Edited December 16, 2013 by AutID https://iblockify.wordpress.com/
Exit Posted December 16, 2013 Posted December 16, 2013 ^^The code I posted works for sure. Maybe you need newer WinHttp.au3. @trancexx, really sorry to disappoint you, but ..... see my log: >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\MyName\Data\Autoit\try99.au3" /UserParams +>13:53:46 Starting AutoIt3Wrapper v.2.1.3.0 SciTE v.3.3.6.0 ; Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64) >Running AU3Check (3.3.9.24) from:C:\Program Files (x86)\AutoIt3\Beta +>13:53:46 AU3Check ended.rc:0 >Running:(3.3.9.24):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\MyName\Data\Autoit\try99.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop !> Starting in DebugMode.. Line: @error-@extended: Line syntax 0001: 0-0: #AutoIt3Wrapper_Run_Debug_Mode=Y 0002: 0-0: #include "WinHttp.au3" 0003: 0-0: $sUsername = "Myid" 0004: 0-0: $sPassword = "Mypw" 0007: 0-0: $sUrl = "https://account.dyn.com/entrance/" 0010: 0-0: $hOpen = _WinHttpOpen() 0012: 0-0: $hConnect = _WinHttpConnect($hOpen, $sUrl) 0015: 1-0: $sRead = _WinHttpSimpleFormFill($hConnect, Default, _ ; login page "C:\Users\MyName\Data\Autoit\try99_DebugIt.au3" (40) : ==> Error parsing function call.: $sRead = _WinHttpSimpleFormFill($hConnect, Default, Dim $__errcstvppoi[2] = [@Error, @Extended] $sRead = _WinHttpSimpleFormFill($hConnect, Default, Dim $__errcstvppoi[2] = [@Error, @Extended^ ERROR ->13:53:46 AutoIt3.exe ended.rc:1 >Exit code: 1 Time: 0.542 Did anyone tried my solution in post #6 above? It is working flawlessly since beginning of this stupid DYN requirement. It first checks availability of connection and sets a message box in case of error. If successful, it only shows a 5 second conformation of success in the system tray. You even don't see the unloved Internet explorer. All browser windows are hidden. Give it a try App: Au3toCmd UDF: _SingleScript()
AutID Posted December 16, 2013 Posted December 16, 2013 @trancexx, really sorry to disappoint you, but ..... see my log: >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\MyName\Data\Autoit\try99.au3" /UserParams +>13:53:46 Starting AutoIt3Wrapper v.2.1.3.0 SciTE v.3.3.6.0 ; Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64) >Running AU3Check (3.3.9.24) from:C:\Program Files (x86)\AutoIt3\Beta +>13:53:46 AU3Check ended.rc:0 >Running:(3.3.9.24):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\MyName\Data\Autoit\try99.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop !> Starting in DebugMode.. Line: @error-@extended: Line syntax 0001: 0-0: #AutoIt3Wrapper_Run_Debug_Mode=Y 0002: 0-0: #include "WinHttp.au3" 0003: 0-0: $sUsername = "Myid" 0004: 0-0: $sPassword = "Mypw" 0007: 0-0: $sUrl = "https://account.dyn.com/entrance/" 0010: 0-0: $hOpen = _WinHttpOpen() 0012: 0-0: $hConnect = _WinHttpConnect($hOpen, $sUrl) 0015: 1-0: $sRead = _WinHttpSimpleFormFill($hConnect, Default, _ ; login page "C:\Users\MyName\Data\Autoit\try99_DebugIt.au3" (40) : ==> Error parsing function call.: $sRead = _WinHttpSimpleFormFill($hConnect, Default, Dim $__errcstvppoi[2] = [@Error, @Extended] $sRead = _WinHttpSimpleFormFill($hConnect, Default, Dim $__errcstvppoi[2] = [@Error, @Extended^ ERROR ->13:53:46 AutoIt3.exe ended.rc:1 >Exit code: 1 Time: 0.542 Did anyone tried my solution in post #6 above? It is working flawlessly since beginning of this stupid DYN requirement. It first checks availability of connection and sets a message box in case of error. If successful, it only shows a 5 second conformation of success in the system tray. You even don't see the unloved Internet explorer. All browser windows are hidden. Give it a try You are far away from understanding what is going on https://iblockify.wordpress.com/
Exit Posted December 16, 2013 Posted December 16, 2013 You are far away from understanding what is going on So please explain App: Au3toCmd UDF: _SingleScript()
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