Jump to content

How to press tab until it reaches a link?


 Share

Recommended Posts

Basicly, I'm trying to create a script that goes to a website, goes to the newest picture and opens it, downloads it and moves on to the next picture.

On the picture page, there is a link that says download full resolution, when clicked it opens up an dl box.

But if im going to download multiple pictures, the link is going to change, so how I scroll with tab until it reaches that text, and then clicks it? Also the ammount of tab presses needed changes.

Then to problems further ahead. Can you just tab until it reaches the save button, and then press enter? Also moving on to the next picture, is also a button. As far as I understand, the problem here would be, is it possible to detect a specific button? The window info tool didn't really do anything, when I decided to try it aswell.

Or am I asking too much? :) Also it seems that my english is a bit bad at the moment, so i'll try to clear up if you don't understand something.

Thanks.

Link to comment
Share on other sites

have a look at the _IELinkGetCollection() in the help file

each website needs a unique approach.

give us a link?

you can also obtain the link by looping through the source of the website _Inetgetsource()

then use _inetget() to download your image

Remember you are using URLs to navigate through the website & not buttons!!!

So work with URLs

for example always look at the url of the image & the the url of the thumbnail, maybe you can logically recreate the URL for all images on the website.

for example if image url is :

www......com/images/1.jpg

www......com/images/2.jpg

then you just make a loop that counts from 1 to the nr of images.

very simple.

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Well, heres what I have:

#include <IE.au3>
$oIE = _IECreate("http://imgur.com/r/pics")
Send ("{F6}")
Send("{TAB 15}")
Send("{ENTER}")
AutoItSetOption ( "WinTitleMatchMode", 2)
WinWaitActive ("Windows Internet Explorer")
_IELinkClickByText($oIE, "Download full resolution")

That winwait might be useless though. So what that does is it goes to the website, goes to the newest pic, and clicks the dl button. Slowly it seems, but at least it does it. Now I would need it to save the image and then go to the next image, save, next...

You might ask where this is needed, well I have a few days off from school here and wanted to finally check out autoit :)

Link to comment
Share on other sites

That winwait might be useless though. So what that does is it goes to the website, goes to the newest pic, and clicks the dl button. Slowly it seems, but at least it does it. Now I would need it to save the image and then go to the next image, save, next...

Edit; this is for win xp & IE 6.0, if u using some some other windows, this may not work,

Like I said earlier, work with urls, you want your prog to work in the background. this website is very friendly & its very simple to dl images.

First look that the Thumbnail image address, then open the image in full size & look at the address again:

http://i.imgur.com/YpAG3b.jpg

http://i.imgur.com/YpAG3.jpg

Note that they are very similar. now open your image & save it as manually & then click the download full resolution image.

Compare the size of 2 images, they are identical. This settles it, to dl your images all you need is a collection of thumbnail image URLS & then you simply remove the b from the url.

Also note when doing those downloaders, dont download too fast nonstop, try to be user friendly by downloading 1 image each 1 second.

In my code change $itrynottoabusebandwighttoomuch to true, then it will work.

Second, dont waist website bandwight, disable images in IE before opening webpage.

#include <IE.au3>
$itrynottoabusebandwighttoomuch = False

; dont display images in IE
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMain", "Display Inline Images", "REG_SZ", "no")

DirCreate(@ScriptDir & 'images')

$oIE = _IECreate("http://imgur.com/r/pics/new", 0,1,1)
$oImgs = _IEImgGetCollection ($oIE)
$iNumImg = @extended

For $oImg In $oImgs

  If stringinstr($oImg.src, 'b.') And stringinstr($oImg.src, 'imgur.com') Then

    $url = StringReplace($oImg.src, 'b.', '.')

    if $itrynottoabusebandwighttoomuch = True Then

     InetGet($url, @ScriptDir & 'images' & $oImg.nameProp)

    EndIf

    ConsoleWrite($oImg.src & ' ' & $url & @LF)

    Sleep(1000)
  EndIf
Next

_IEQuit($oIE)

;Diplay images
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMain", "Display Inline Images", "REG_SZ", "yes")
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Using win 7 & IE 9 I think, and it's working well, so thank you for that. Kinda lost understanding in the part where the if statements start. And was wondering what those _IEcreate flags do, but I'll go google that now.

But the reason why I wanted to use Download full resolution image, was that then it saves it with its proper name. And as far as my understanding goes, this site only loads more pictures, when you go to the end of the page, and I suppose your script doesn't somehow bypass this. Or then im just stupid again :) Also for 20 second testing, I did abuse bandwidth, becouse I'm not sure if those reg edits are valid for 64bit win 7 (I'm sorry for this too ;))

But thank you for being helpfull & replying fast.

Link to comment
Share on other sites

Using win 7 & IE 9 I think, and it's working well, so thank you for that. Kinda lost understanding in the part where the if statements start. And was wondering what those _IEcreate flags do, but I'll go google that now.

Select _IEcreate in your script & press F1. A help file will pop out. Its all written there.

I didnt look too closely at the website. just disabled images so it would load the page instantly.

I recommend you check for the source code of the webpage & see how it displays the links. Some links my be java scripted so _ie_link_getcollection may not work. In this case you ether will have to see if you can recreate the urls logically or from the webpage source.

If stringinstr($oImg.src, 'b.') And stringinstr($oImg.src, 'imgur.com') Then

$oImg.src is the image url

And string is basically any line of text, so if image url contains text b. and if in the same text string there is text imgur.com then do something

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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...