Reputation: 21
My script automates the room booking process at my school for group projects. I have created an automatic log-in script which works fine. Now I would like to access different elements from the loaded page (check boxes, radio buttons...).
How can I save various elements from the page that I have logged-in into and perform certain actions on them?
Func SignIn()
Global $window = _IECreate("https://roombooking.au.dk/classes/Login.aspx? ReturnUrl=%2fclasses%2fbook.aspx")
_IELoadWait($window)
If @error Then Return
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
Local $username = _IEGetObjByName($window,"ctl00$Main$UsernameBox")
Local $password = _IEGetObjByName($window,"ctl00$Main$PasswordBox")
Local $button = _IEGetObjByName($window, "ctl00$Main$LoginBtn")
_IEFormElementSetValue($username,"abc")
_IEFormElementSetValue($password,"123")
_IEAction ($button, "click")
EndFunc
Func Room()
Local $SelectRoom = _IEGetObjByName(**???**,"ctl00$Main$ChangeReqsBtn")
_IELoadWait($bwindow)
_IEAction($s526,"click")
EndFunc
Upvotes: 1
Views: 648
Reputation: 2946
From the Help File:
#include <IE.au3>
_IEGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )
$oObject Object variable of an InternetExplorer.Application, Window or Frame object
$sName Specifies name of the object you wish to match
$iIndex If name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified objects
In your case the code will be something like:
Local $SelectRoom = _IEGetObjByName($window,"ctl00$Main$ChangeReqsBtn")
Upvotes: 1
Reputation: 3002
AutoIt offers many different approaches to HTML document retrieval. Without providing concerning source code it can only be guessed.
HTML source of document is returned by _IEDocReadHTML() (assuming you're using IE.au3 UDF). Example:
#include <IE.au3>
Global Const $oIE = _IECreate('http://www.google.com/')
Global Const $sDocHTML = _IEDocReadHTML($oIE)
_IEQuit($oIE)
ConsoleWrite($sDocHTML & @LF)
Exit 0
Mentioned UDF contains functions to set values to form elements (lookup _IEForm...() in AutoIt's user defined function reference).
Upvotes: 1