Jump to content

Trouble getting IE.au3 to work


neogia
 Share

Recommended Posts

Ok, so I'm making my feeble attempt at automating the windows updates via browser.

I can't seem to make IE.au3 find the "Express" button: I've tried these

$win = _IECreate()
WinWaitActive("about:blank")
_IENavigate($win, "windowsupdate.microsoft.com")
$btns = _IETagNameGetCollection($win,"button")
For $btn in $btns
    MsgBox(0,"",$btn.id)
Next

With page already loaded and "Express" and "Custom" buttons showing

$win = _IEAttach("Microsoft Windows Update")
$btns = _IETagNameGetCollection($win,"button")
For $btn in $btns
    MsgBox(0,"",$btn.id)
Next

These two scripts just exit, showing no MsgBox, so I tried running them in Scite and I get the error message:

C:\Program Files\AutoIt3\beta\Include\IE.au3 (1190) : ==> The requested action with this object has failed.

$win = _IEAttach()
$src = _IEBodyReadHTML($win)
While StringInStr($src,"java script:parent.fnExpressScan(event)") == 0
    $src = _IEBodyReadHTML($win)
    MsgBox(0,"src",$src)
WEnd

This one seems like the most promising, because if you right-click on the MS Updates webpage (in the frame with the buttons) and View Source, you can search through the source to find

<button id="aExpress" style="cursor:hand" onclick="java script:parent.fnExpressScan(event);" title="Find and install only the most important updates for your computer">Express</button>

And then you can just use _IENavigate($win, "java script:parent.fnExpressScan(event)"), and this "clicks" the button. I've tested this and it works. But when I run that third script it only finds:

<FRAME class=storeUserData style="BORDER-BOTTOM: white 1px solid" name=eToolbar src="mstoolbar.aspx?ln=en-us" noResize><FRAMESET frameSpacing=0 cols=200,*,0><FRAME name=eTOC src="toc.aspx?ln=en-us"><FRAME name=eContent src="splash.aspx?page=0&ln=en-us"><FRAME style="DISPLAY: none" name=eReporting noResize width="0px" height="0px"></FRAMESET><FRAME style="BORDER-TOP: white 1px solid" name=eFooter src="footer.aspx?ln=en-us" noResize>

I can't find where _IEBodyReadHTML() is finding that source. If possible, I'd like to know if there is a way to specify which source _IEBodyReadHTML() reads from. Any help is as always greatly appreciated.

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
Share on other sites

You are getting the source for a given frame - I believe that IE.au3 provides a way for enumerating the frames, then dealing with them by virtue of the frame index ( or maybe even the name) -

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

I didn't look at steve8tch's code -- I may be that it is all explained well in there... but here is the logic...

Right-click on the content area near your buttons and choose "Properties". You'll see the the URL is /something/.../splash.aspx

Do a View -> Source from the broswer and you'll see a named frame referencing that page:

<frame name='eContent'  src='splash.aspx?page=0&ln=en-us' />

So, an

$oFrame = _IEFrameGetObjByName($oIE, "eContent")
should give you a reference to the appropriate frame.

As you noted, the Express and Custom elements are type "Button". The fist has an ID, "aExpress" and sloppily, the second does not:

<button id="aExpress" style="cursor:hand" onclick="java script:parent.fnExpressScan(event);" title="Find and install only the most important updates for your computer">Express</button>

<button style="cursor:hand" onclick="java script:parent.fnScan(event);"width=180 title="Find and choose from all available updates for your computer">Custom</button>

I think you've got the rest of the logic -- just use $oFrame where you would have used $oIE on a non-frame page.

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

@valuater: I attempted using this tool, but it locks up after I "Download Source" then try to view the form objects. At least on windows update.

@steve8tch: Thank you for the code, I'm unfortunately at work and can't view it. I'll post my thoughts on your code when I get home to look at it.

@Dale(Edit: Sorry Dale, I was in a rush): Thanks for clearing that up. I've done my share of HTML/PHP/MySQL, but never framed pages. My logic before was that the source taken from near the buttons would contain the frames, but in reality it was a frame. I was stumped when I searched the source for "<frame" and found nothing, then "frame" and found <iFrame. I think you've shed just enough light to put me on the right track, thanks.

Edited by neogia

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
Share on other sites

  • Moderators

@valuater: I attempted using this tool, but it locks up after I "Download Source" then try to view the form objects. At least on windows update.

@steve8tch: Thank you for the code, I'm unfortunately at work and can't view it. I'll post my thoughts on your code when I get home to look at it.

@Dave: Thanks for clearing that up. I've done my share of HTML/PHP/MySQL, but never framed pages. My logic before was that the source taken from near the buttons would contain the frames, but in reality it was a frame. I was stumped when I searched the source for "<frame" and found nothing, then "frame" and found <iFrame. I think you've shed just enough light to put me on the right track, thanks.

Who's Dave? :o

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Do you want to give this a go.

I wrote this to learn how to use the WUA object.

I can use this at home to update my PCs successfully. :o

At work - I couldn't get this to work through a firewall that required authentication :geek: - so I didn't put any more work into it.

it requires beta

wua.au3menu.au3

Wow, steve8tch, that's some impressive stuff, where on earth did you dredge up the Microsoft.update.session object? I'd really like to know your reference for creating that script.

@dale: Say I were to go with the browser update as opposed to the microsoft.update.session method, how can I reliably determine when the "eContent" frame is loaded and I can call "java script:parent.fnExpressScan(event)" or otherwise click the express button? I mean I could just sleep(10000) after the page loads, but what if the computer hiccups, and I try to fire too early? I could break my whole script:

$frame = _IEFrameGetObjByName($win, "eContent");this finds the frame object correctly
_IELoadWait($frame);why can't I do something like this?

Or can I keep checking the source of "eContent" until it contains, I don't know "aExpress", the id of the button? Thanks.

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
Share on other sites

Wow, steve8tch, that's some impressive stuff, where on earth did you dredge up the Microsoft.update.session object? I'd really like to know your reference for creating that script.

@dale: Say I were to go with the browser update as opposed to the microsoft.update.session method, how can I reliably determine when the "eContent" frame is loaded and I can call "java script:parent.fnExpressScan(event)" or otherwise click the express button? I mean I could just sleep(10000) after the page loads, but what if the computer hiccups, and I try to fire too early? I could break my whole script:

$frame = _IEFrameGetObjByName($win, "eContent");this finds the frame object correctly
_IELoadWait($frame);why can't I do something like this?

Or can I keep checking the source of "eContent" until it contains, I don't know "aExpress", the id of the button? Thanks.

No need to sleep... the _IELoadWait just as you have it here should work.

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

No need to sleep... the _IELoadWait just as you have it here should work.

Dale

Oh, sure it works now that you've said it will. I swear I tried this exact code:

#include <IE.au3>

Opt("WinTitleMatchMode", 2)

$win = _IECreate()
WinWaitActive("about:blank")
_IENavigate($win,"windowsupdate.microsoft.com")
$frame = _IEFrameGetObjByName($win, "eContent")
_IELoadWait($frame)
MsgBox(0,"","Loaded")

just minutes before posting here. I guess retyping code fixes most mistakes... either that or you're magic or something.. I'll go with the latter.

EDIT: sp

Edited by neogia

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...