Sign in to follow this  
Followers 0
dickep

IE Help for noob

6 posts in this topic

I have been using Autoit for a few years and now will need to use it for website testing.

That is where I need some help/advice. Where is the best place to learn the functions and examples. Yes, I have read the help files, but am not sure of a lot of the information. I am a visual learner so examples are best for me.

What I really need to do is to be able to open a website, find some text (usually a URL that is NOT a link), highlight it, copy it and paste that into the address bar. Is it possible?

Also, does most of the _IE calls also work with Mozilla? I am going to have to test Mozilla (Firefox) along with IE so.... just asking

Thanks and keep up the GREAT help!!

Ep

Share this post


Link to post
Share on other sites



I have found the help file (both local and online), the best place to learn functions, for the examples provided there. To use Firefox scripts, use this UDF - FF.au3 (V0.6.0.0b)


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I consider myself a visual learner and I've learned most of what I know through the help file.

Obviously there needs to be a pattern so that you can identify for where the text is. For instance inside a specific HTML tag such as a named div or something would be most helpful. But http:// .com,.net,.org etc can all be used as a reference point. Do you have an example of the website or its html?

Some functions you might want to look at are

_InetGetSource

ClipPut

_RunDos

_StringBetween (maybe)

StringRegExp

Some pseudo-code

<html>

<head>

<title>This file is named file.html</title>

<body>

<div id=link>http://www.test.com</div>

</body>

</html>

$src = _InetGetSource("http://www.awebsite.com/file.html")

$link = _StringBetween($src,"<div id=link>","</div>")

_RunDOS("start "&$link)

That should grab "http://www.test.com" out of the source and open it in the default web browser. If you want a specific browser then you could probably do it with the Run command. Or use AU3Info to get the correct class ids and such and then put the string there and send the Enter key.

Note that example is very basic and easy because of the div id tag. If you dont have the luxury of neat orginized html then it will be a little trickier but still possible (StringRegExp). If you have a sample that would be nice.

Edited by Marklar

Share this post


Link to post
Share on other sites

Ok, try this one Typical and I want to find and copy to the address bar (or at least try to open/access) the hotfile URL(s) each one at a time.

This is just like the one I will be trying to test but, because of what I do, I cannot put the actual website there, sorry.

Thanks

Ep

Share this post


Link to post
Share on other sites

So the actual website is from downarchive.com? If so then it's easy. You should look at the string UDFs in the help file. _StringExplode, _StringBetween, StringinStr (standard function), etc. You want to find patterns and act accordingly.

This may not be the most optimal way but it works and is easier than

using Regular Expressions.

The downarchive site seems to have a simple pattern

The download links are all between these two tags

$txt = _StringBetween($src,"<!--QuoteEBegin-->","<!--QuoteEnd-->")

And then each link ends with <br />

$explode = _StringExplode($txt[0],"<br />")

You then get an array variable named $explode and each element has a link in it.

It's taken all the text between <!--QuoteEBegin--> and <!--QuoteEnd-->

The StringExplode function breaks it up into different pieces based on a delimiter

Imagine how Excel separates a CSV file up. For each comma it comes across the preceding

text is put into its own cell. String Explode works the same way except instead of a comma

you can use anything you want. Luckily each link has <br /> at the end of it... That's our

comma

It's very similar to the explode function in PHP. So if the Autoit Helpfile doesnt make sense then

look at explode() in php. Same concept.

You should then step through each element in the explode array and test it's value

If it's value is acceptable then insert it into a new array

Dim $array[UBound($explode)]
For $i = 1 To UBound($explode)
    If StringInStr($explode[$i-1],"http://hotfile") Then
        $array[$i-1] = $explode[$i-1]
    EndIf
Next

So now you have a new array with each element a link to hotfile.com

You can then open each link individually in a new browser window

Final Code looks like this

#include <String.au3>
#include <INet.au3>
#include <Array.au3>
#include <Process.au3>

$url = "http://www.downarchive.com/ebooks/magazine/73575-beaux-arts-magazine-january-december-2009-all.html"

$src = _INetGetSource($url)

$txt = _StringBetween($src,"<!--QuoteEBegin-->","<!--QuoteEnd-->")

$explode = _StringExplode($txt[0],"<br />")

Dim $array[UBound($explode)]

For $i = 1 To UBound($explode)
    If StringInStr($explode[$i-1],"http://hotfile") Then
        $array[$i-1] = $explode[$i-1]
        _RunDOS("start "&$array[$i-1])
    EndIf
Next

Hopefully that's what you want. If not it gives you a good idea on what to look far, atleast for websites similar to that one. As for copy and pasting the URL to the window. You can replace

_RunDOS("start "&$array[$i-1])

with

ClipPut($array[$i-1])
;now add code for sending
; keystrokes

Share this post


Link to post
Share on other sites

wow, Marklar, you really helped!! Your explanation was SO GOOD even I can now get things a little better. I still need, really, some experience, but your explanation and example(s) are, as the British say, "spot on". Thank you very much.

Now for some application testing........

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