Sign in to follow this  
Followers 0
bobthenob

_IEGetObjByName

19 posts in this topic

hi im using _IEGetObjByName

this is my code it some times works but not always

i get the objects name should i then do somthing before sending or should i control send

what does this do ($oIE)

and this ($oForm)

ive searched the help file?

$oIE = _IECreate("website")
_IELoadWait($oIE)
winactivate ("[class:IEFrame]","")
_IEGetObjByName($oIE, "frmLogin")
send ("user")
send ("{TAB}")
Send ("pass")
send ("{ENTER}")

cheers

Share this post


Link to post
Share on other sites



hi im using _IEGetObjByName

this is my code it some times works but not always

i get the objects name should i then do somthing before sending or should i control send

what does this do ($oIE)

and this ($oForm)

ive searched the help file?

$oIE = _IECreate("website")
_IELoadWait($oIE)
winactivate ("[class:IEFrame]","")
_IEGetObjByName($oIE, "frmLogin")
send ("user")
send ("{TAB}")
Send ("pass")
send ("{ENTER}")

cheers

The IE.au3 functions work with the IE Document Object Model (DOM). $oIE is typically the object reference to the IE application object, and $oForm is typically an object reference to an HTML FORM in the referenced web page.

Send() is for any generic window that happens to be active.

_IEGetObjByName() would be used to get the object reference to a particular element of the DOM (i.e. username or password INPUT tag), and then you could use that reference to set the value directly into the element. See the help file example for _IEFormElementSetValue().

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks for your reply

ill look at that

Ive look at the help file cheers thats sent me in the right direction

but one question

i have to put a sleep in or the script just closes

i tryed _IEloadwait but that didnt help is there another way than the sleep as this will cause a problem if the website is slow loading

as the site loads the username and password arnt there till its loaded?

thanks again for your help

#include <IE.au3>
$oIE = _IECreate ("wesite")
sleep(10000)
winactivate ("[class:IEFrame]","")
$o_form = _IEFormGetObjByName ($oIE, "frmlogin")
$o_login = _IEFormElementGetObjByName ($o_form, "username")
$o_password = _IEFormElementGetObjByName ($o_form, "password")
$o_signin = _IEFormElementGetObjByName ($o_form, "btnSubmit")
$username = "username"
$password = "password"
; Set field values and submit the form
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
Edited by bobthenob

Share this post


Link to post
Share on other sites

thanks for your reply

ill look at that

Ive look at the help file cheers thats sent me in the right direction

but one question

i have to put a sleep in or the script just closes

i tryed _IEloadwait but that didnt help is there another way than the sleep as this will cause a problem if the website is slow loading

as the site loads the username and password arnt there till its loaded?

thanks again for your help

#include <IE.au3>
$oIE = _IECreate ("wesite")
sleep(10000)
winactivate ("[class:IEFrame]","")
$o_form = _IEFormGetObjByName ($oIE, "frmlogin")
$o_login = _IEFormElementGetObjByName ($o_form, "username")
$o_password = _IEFormElementGetObjByName ($o_form, "password")
$o_signin = _IEFormElementGetObjByName ($o_form, "btnSubmit")
$username = "username"
$password = "password"
; Set field values and submit the form
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
The function _IECreate() calls _IELoadWait() by default unless you set $f_wait = 0 in the parameters. Sometimes _IELoadWait() can't tell that some javascript or other operation is not done yet. From the remarks in the help file under _IELoadWait():

Browser scripting security restrictions may sometimes prevent _IELoadWait from guaranteeing that a page is fully loaded and can occasionally result in untrapped errors. In these cases you may need to avoid calling _IELoadWait and attempt to employ other methods of insuring that the page load has completed. These methods might include using a Sleep command, examining browser status bar text and other methods.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

cheers

it looks like ill have to use the sleep

as a host checker runs

thanks for the reply

Share this post


Link to post
Share on other sites

hi im back

ive made a script that gets the statusbartext into a textfile

the last thing that appears on the statusbar is (1 item remaining) Downloading picture

so with this info ive tryed this script but cant see why it dosnt work

any help would be great cheers

Opt("WinTitleMatchMode", 2)

$url = "website"

WaitLoad()

Func WaitLoad()

Dim $state

Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir)

WinActivate("[class:IEFrame]","")

Do

$state = StatusbarGetText("[class:IEFrame]","")

Sleep(250)

Until $state = "(1 item remaining) Downloading picture"

MsgBox(0, "", "Success!")

EndFunc

Share this post


Link to post
Share on other sites

hi im back

ive made a script that gets the statusbartext into a textfile

the last thing that appears on the statusbar is (1 item remaining) Downloading picture

so with this info ive tryed this script but cant see why it dosnt work

any help would be great cheers

Do it like this so you can debug what it's getting:
Do
     $state = StatusbarGetText("[class:IEFrame]","")
     ToolTip("Debug: $state = " & $state)
     Sleep(250)
Until $state = "(1 item remaining) Downloading picture"

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

hi thanks ive tryed that (could help me in other thing i nmake) things flash by so quick but i did see 1 item remaing ?

this is what i used to see what text was there

AutoItSetOption("WinTitleMatchMode", 2)

#include <IE.au3>

$oIE = _IECreate ("website)

Local $sStatus

;$x = StatusbarGetText("Internet Explorer")

While Not ($sStatus = "Status Bar Text: jim")

$sStatus = _IEPropertyGet ( $oIE, "statustext")

$file = FileOpen("C:\test.txt", 1)

FileWrite($file, $sStatus & @CRLF)

FileClose($file)

WEnd

i removed the sleep and it still didnt work ive now changed the text to search for to

Opt("WinTitleMatchMode", 2)

$url = "website"

WaitLoad()

Func WaitLoad()

Dim $state

Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir)

WinActivate("[class:IEFrame]","")

Do

$state = StatusbarGetText("[class:IEFrame]","")

Sleep(250)

Until $state = "(start Downloading from site: then website "

MsgBox(0, "", "Success!")

EndFunc

and it works thanks

in the help file for statusbargetext

it says part

[optional] The "part" number of the status bar to read - the default is 1. 1 is the first possible part and usually the one that contains the useful messages like "Ready" "Loading...", etc.

can i read just some of the statusbar text? Edited by bobthenob

Share this post


Link to post
Share on other sites

Instead of trusting the default, did you try explicitly setting the "part" to read?

:)

P.S. You might like _FileWriteLog() as an easier one-step way to log things to a file, plus it time-tags the entries.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

hi thanks for your reply

P.S. You might like _FileWriteLog() as an easier one-step way to log things to a file, plus it time-tags the entries.

this will be handy

Im not sure how to do this bit

Instead of trusting the default, did you try explicitly setting the "part" to read?

cheers

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Im not sure how to do this bit

cheers

I meant for example:
$sStatus1 = StatusbarGetText("[class:IEFrame]", "", 1)
$sStatus2 = StatusbarGetText("[class:IEFrame]", "", 2)
$sStatus3 = StatusbarGetText("[class:IEFrame]", "", 3)

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

what does the 2 and 3 do ?

sorry to be so dumb

Share this post


Link to post
Share on other sites

i always chechk the help file first

but if your a nob like me you cabnt always undetrstand what its showing you

[optional] The "part" number of the status bar to read - the default is 1. 1 is the first possible part and usually the one that contains the useful messages like "Ready" "Loading...", etc.

so what is 2

where does 1 part stop and the next start? can you show me in the below statusbartext

(1 item remaining) Downloading picture

cheers

Share this post


Link to post
Share on other sites

i always chechk the help file first

but if your a nob like me you cabnt always undetrstand what its showing you

so what is 2

where does 1 part stop and the next start? can you show me in the below statusbartext

(1 item remaining) Downloading picture

cheers

First, on actual testing, most everything interesting in the IE status bar seems to be in part 1. Monitoring parts 1 thru 10 in a loop while refreshing the www.autoitscript.com page just shows "(3 items remaining) Waiting for http://www.autoitscript.com/..." and then "Done" in part 1. All other parts remained blank.

I guess I'm losing track of what your question was. Were you unable to read the status bar? Or did the result you got back not match what you saw on the window? Or what?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

thanks for the help

i am now usng

Until $state = "(start Downloading from site: then website "

then a wait of 8 seconds wich seem to work most of the time

the last thing in the status bar is

(1 item remaining) Downloading picture

useing this to write to a text file is what i found but if i use it

it dosnt work

AutoItSetOption("WinTitleMatchMode", 2)
#include <IE.au3>
$oIE = _IECreate ("website)

Local $sStatus
;$x = StatusbarGetText("Internet Explorer")
While Not ($sStatus = "Status Bar Text: jim")
$sStatus = _IEPropertyGet ( $oIE, "statustext")
$file = FileOpen("C:\test.txt", 1)
FileWrite($file, $sStatus & @CRLF)
FileClose($file)
WEnd

in my code how would i test other parts of the status bar would it be like this

Opt("WinTitleMatchMode", 2)
$url = "website"
WaitLoad()

Func WaitLoad()
Dim $state
Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir)
WinActivate("[class:IEFrame]","")
Do
$state = StatusbarGetText("[class:IEFrame]","")
$state = StatusbarGetText("[class:IEFrame]","2")
$state = StatusbarGetText("[class:IEFrame]","3")
Sleep(250)
Until $state = "(start Downloading from site: then website "
MsgBox(0, "", "Success!")
EndFunc

thanks agian for your help

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I thought you wanted to monitor the status bar text until it said "(1 item remaining) Downloading picture". That (with logging to a file added) looks like this:

#include <IE.au3>
#include <File.au3>

Global $oIE = _IECreate ("website")
Global $sLogFile = "C:\test.txt"
Global $sStatus = ""
While 1
    $sStatus = _IEPropertyGet($oIE, "statustext")
    _FileWriteLog($sLogFile, "Statustext = " & $sStatus)
    If $sStatus = "(1 item remaining) Downloading picture" Then
        _FileWriteLog($sLogFile, "Done monitoring IE.")
        ExitLoop
    EndIf
    Sleep(8000) ; 8sec delay
WEnd

I don't know where "Status Bar Text: jim" comes from or what it has to do with this.

If everything you want is in the default part 1 of the status bar there is no reason to worry about the other parts. Forget I brought that up.

If you DO need to monitor something in another part, then don't pull all the parts into the same variable before doing something with it, because you are overwriting the contents of $state.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

hi thanks again

i just put the

I don't know where "Status Bar Text: jim"

so i could find what was in the status bar so it would just keep checking

you are right the bit i am trying to get is

If $sStatus = "(1 item remaining) Downloading picture" Then

but i cant get it to see this but if i save it to a text file it does show me

sorry im not making much sense any way ive got it to work good enough thanks again for your help

Share this post


Link to post
Share on other sites

hi thanks again

i just put the

so i could find what was in the status bar so it would just keep checking

you are right the bit i am trying to get is

but i cant get it to see this but if i save it to a text file it does show me

sorry im not making much sense any way ive got it to work good enough thanks again for your help

If it appears to log exactly what you are looking for, but not match it on your compare, consider stray whitespace in the return. There may be non-printing characters (i.e. TAB or SPACE) you don't see, making the log output look like a match when it's not. If this is a factor:
#include <IE.au3>
#include <File.au3>

Global $oIE = _IECreate("website")
Global $sLogFile = "C:\test.txt"
Global $sStatus = ""
Global $sSearch = "(1 item remaining) Downloading picture"

$sSearch = StringStripWS($sSearch, 8) ; Remove all whitespace
While 1
    $sStatus = _IEPropertyGet($oIE, "statustext")
    _FileWriteLog($sLogFile, "Statustext = " & $sStatus)
    If StringLeft(StringStripWS($sStatus, 8), StringLen($sSearch)) = $sSearch Then
        _FileWriteLog($sLogFile, "Done monitoring IE.")
        ExitLoop
    EndIf
    Sleep(8000) ; 8sec delay
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0