E1M1 Posted February 28, 2011 Share Posted February 28, 2011 I am trying to automate login, but I cant get it fill username and password. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 800, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 800, 360) GUISetState() ;Show GUI _IENavigate ($oIE, "http://ee.ekool.eu") $oDiv = _IEGetObjById($oIE, "username") _IEFormElementSetValue($oDiv, "user") $oDiv = _IEGetObjById($oIE, "password") _IEFormElementSetValue($oDiv, "pass") ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit also doesnt work thisway $oDiv = _IEGetObjByName ($oIE, "username") _IEFormElementSetValue($oDiv, "user") $oDiv = _IEGetObjByName($oIE, "password") _IEFormElementSetValue($oDiv, "pass") edited Link to comment Share on other sites More sharing options...
PowerCat Posted February 28, 2011 Share Posted February 28, 2011 (edited) Heya E1M1 Your page is a bit tricky cause you need to wait after it's loaded before you can access stuff. (Notice the flash-like loading icon that appears for 1-3 seconds when you go to https://ee.ekool.eu/index_et.html) Here's some working code: #include <ie.au3> $oIE = _IECreate("https://ee.ekool.eu/index_et.html") Sleep(5000) ; the sleep seems important cause the page doesn't "load" then it's loaded. $oTable = _IETableGetCollection($oIE, 1) ; the login boxes are also in a table. (press F12, and then click on the little arrow icon and click the editbox) $uname = _IEGetObjById($oTable, "username") _IEFormElementSetValue($uname, "user") $pw = _IEGetObjById($oTable, "password") _IEFormElementSetValue($pw, "pass") Also is your name a reference to the Doom level? Edited February 28, 2011 by PowerCat Link to comment Share on other sites More sharing options...
Cake Posted February 28, 2011 Share Posted February 28, 2011 Have fun! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 800, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 800, 360) GUISetState() ;Show GUI _IENavigate ($oIE, "https://ee.ekool.eu/index_et.html") _IELoadWait($oIE) ; Make sure the dom is fully loaded. While 1 ; Loop for checking the contents of "topmenu", since the login form is loaded with ajax. $oTop = _IEGetObjById($oIE, "topmenu") ; Get the div with id "topmenu" If $oTop.innerHTML <> '' Then ; Check the contents of "topmenu" to see if the login form is loaded yet. ExitLoop ; Exit the loop if the login form is loaded, else check again. EndIf Sleep(100) ; Wait 100ms to reduce cpu usage. Also there is no point in checking if the form is loaded more often. WEnd $oDiv = _IEGetObjByName($oIE, "username") ; Get the userneme input by it's name, since it dosn't have an id. _IEFormElementSetValue($oDiv, "user") $oDiv = _IEGetObjByName($oIE, "password") ; Get the password input by it's name, since it dosn't have an id. _IEFormElementSetValue($oDiv, "pass") ; Alternative method: $oDiv.value = "something" ; For more information about ajax (Asynchronous Javascript and XML). Visit: http://en.wikipedia.org/wiki/Ajax_(programming) ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit ~Cake Link to comment Share on other sites More sharing options...
AutoBert Posted March 1, 2011 Share Posted March 1, 2011 (edited) and here another way to Rome ee.ekool.eu expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: AutoBert: http://www.autoit.de/index.php?page=Thread&postID=164679#post164679 Skriptbeispiel für den Umgang mit _IECreateEmbedded, _IEErrorHandlerRegister, _IENavigate, _IEAction GuiCtrlCreateProgress, _IEPropertyGet #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() Global $percent $oIE = _IECreateEmbedded() GUICreate("Embedded Web control Test", 640, 600, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 658, 600) GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO) GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, "https://ee.ekool.eu/index_et.html") ;Loop unil Page is loaded (there is no Error getting the Objekt by ID) $iBegin = TimerInit() Do Sleep(50) $oDiv = _IEGetObjById($oIE, "username") until isObj($oDiv) or (TimerDiff($iBegin) > 10000) ;waiting until Object username is found max 10 seconds ;ConsoleWrite("Ready" & @crlf) $oDiv = _IEGetObjById($oIE, "username") _IEFormElementSetValue($oDiv, "user") $oDiv = _IEGetObjById($oIE, "password") _IEFormElementSetValue($oDiv, "pass") ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop ;more case 's EndSwitch WEnd $oIE.Quit ; close IE $oIE = 0 GUIDelete() ExitEdit: script changed, thanks DaleHohm autoBert Edited March 1, 2011 by AutoBert Link to comment Share on other sites More sharing options...
DaleHohm Posted March 1, 2011 Share Posted March 1, 2011 In the last method, I would change until $oDiv <> 0 to until isObj($oDiv) Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
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