Sign in to follow this  
Followers 0
Guest surefire12345

Code to detect what's written on browser page

5 posts in this topic

I'm a long time user of v2 AutoIt, but there's one thing I've always wanted to be able to do and I'm wondering whether it's now possible in v3.

What I'd like to be able to know is when a certain condition has been met on a browser page. So for example:

Let's say I'm using AutoIt to submit information to a web based form, but I want to know whether the submission has been successful or not. Let's say that the next web page says "success" on it somewhere when the submission has worked.

Is there anyway of programming an AutoIt Script to recognise this outcome. Obviously in this case the Title bar isn't changing to give anything away, so I can't use the Title to move on.

Your thoughts and help are much appreciated.

Michael.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

You can copy everything on the page and read this, example:

Send("^a");select all
Send("^c");copy to clipboard
$text=ClipGet();set text to clipboard

Now use StringInStr() to check for the word "succes" or something, so:

If StringInStr($text,"succes") Then
MsgBox(0,"","Succes")
Else
MsgBox(0,"","Error")
EndIf

You can press Ctrl+V in notepad after executing the first script to see how it looks.

Edited by svennie

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post


Link to post
Share on other sites

And with the COM support in the beta release, it's even easier.

Have a look at just this snippet of code.

$o_object = ObjCreate("InternetExplorer.Application")
If IsObj($o_object) Then
    $o_object.visible = 0
    $o_object.navigate ("http://www.google.com/")
    While $o_object.busy
        Sleep(100)
    WEnd
    $s_Text = $o_object.document.body.innerText
    $o_object.quit()
EndIf

MsgBox(0, 'Page Text', $s_Text)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Or with IE.au3:

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "http://www.google.com/")
MsgBox(0, 'Page Text', $oIE.document.body.innerText)
Edited by DaleHohm

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

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