Jump to content

Clicking a image link in IE


Recommended Posts

I have been viewing many of the topics on this subject of clicking on a link in a table within IE. Unfortunately most haven't worked for me. Yes, I am a newbie here so please be gentle. First off I am using Internet Explorer 7. I have gone to a website that has tables, and one of the tables has image links in it, unfortunately this table isn't the first one. The image links are not <input text> type of links. I would like to go to the table with image links and click on the latest image link. After that the requested Microsoft where do you want to download the file should come up. I would then like to create and pick a location to download this file. Presently, I am not using the AutoIT Beta test, but if it needs to be used I can. Any help would be nice.

Planets come and go. Stars perish. Matter disperses, coalesces, forms into other patterns, other worlds. Nothing can be eternal. Dr. Who

Link to comment
Share on other sites

It doesn't take a lot of code to do this sort of thing, but conceptually you probably have a lot to learn before you will be able to do it on your own.

I suggest you download DebugBar and work through examples in the helpfile for IE Automation with IE.au3 for a bit first to learn about the DOM and the object model of the browser. Then post some code that you tried along with a link to the website you are working with and ask for further assistance.

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

You never have to klick on a image. The link will always be in the code.

Could you show the link/page?

Ok, normally I would love to show the code, but unfortunately on this one I cannot. I will see if I can find something similiar. The big thing is that the images are links in a table that open up in Excel. I just want to activate the latest link and download the data to a folder on a local machine. I also downloaded the Debugger toolbar.

Everyone thanks for the quick reply. I am finding AutoIT a wonderful program!

Planets come and go. Stars perish. Matter disperses, coalesces, forms into other patterns, other worlds. Nothing can be eternal. Dr. Who

Link to comment
Share on other sites

The reason I suggested this would be so difficult is that as the problem was stated, it would involve parsing the cells of a table, finding the cell desired, finding the embedded image (or link), getting a reference to it, giving it focus with _IEAction, and then simulating a click on it with Send or ControlSend (this last step required to be simulated because it was stated that a file download dialog appears - if you click on this with the DOM, AutoIt will pause until the dialog is dismissed). Then you must work with the file dialog with standard Win* functions and then return to IE.au3 processing. Mechanically not that tough, but conceptually challenging for a beginner.

Dale

p.s. @tgreat - img has a .href property, but it is identical to the .src property and is depricated - it is not a link target

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

Link to comment
Share on other sites

The reason I suggested this would be so difficult is that as the problem was stated, it would involve parsing the cells of a table, finding the cell desired, finding the embedded image (or link), getting a reference to it, giving it focus with _IEAction, and then simulating a click on it with Send or ControlSend (this last step required to be simulated because it was stated that a file download dialog appears - if you click on this with the DOM, AutoIt will pause until the dialog is dismissed). Then you must work with the file dialog with standard Win* functions and then return to IE.au3 processing. Mechanically not that tough, but conceptually challenging for a beginner.

Dale

p.s. @tgreat - img has a .href property, but it is identical to the .src property and is depricated - it is not a link target

O okay, Good to know just wrote that in fast reply.(Don't do much work with Images in IE) But could it not be possible to recreate the header to be passed, and do an InetGet or possibly a HTTPPost with the HTTP.au3 UDF? Thus eliminating an Win functions. I know he is just a beginner but it is always good to advance your skills at some point

Link to comment
Share on other sites

A lot of things may be possible, but it will take studying and understanding the possibilities from the page source. Someone just getting started will find this to be a very anbitious project as a first attempt and since he cannot share the source or access to the site it will be hard for others to assist. Thus, I suggested spending time with the helpfile and examples first.

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

A lot of things may be possible, but it will take studying and understanding the possibilities from the page source. Someone just getting started will find this to be a very anbitious project as a first attempt and since he cannot share the source or access to the site it will be hard for others to assist. Thus, I suggested spending time with the helpfile and examples first.

Dale

Thanks for the information. Okay, I have made some progress now. First I am able to open the link I want due to arrays and tables. My next problem in the step, is that the Windows File Download messagebox opens. Now my AutoIT seems to go into pause mode. I would like to click the Save in the Windows File Download. After that I would like to be able to input the location to save the file which would be in the next window.

The code I am using is:

; Wait for Alert window, then click on OK

WinWait("File Download", "")

ControlClick("File Download", "", "[CLASS:Button; TEXT:SAVE; Instance:1;]",1)

_IELoadWait ($oIE)

I believe this was part of an example code, in the AutoIT help. Sorry, I wasn't able to put the code in a fancy setup, still learning this forum interface.

Planets come and go. Stars perish. Matter disperses, coalesces, forms into other patterns, other worlds. Nothing can be eternal. Dr. Who

Link to comment
Share on other sites

CODE
; Wait for Alert window, then click on OK

WinWait("File Download", "")

ControlClick("File Download", "", "[CLASS:Button; TEXT:SAVE; Instance:1;]",1)

_IELoadWait ($oIE)

If you are not sure this is right: just try the "ugly" way with

Sleep(5000)

Mouseclick("left",X,Y)

if that one works you made a mistake in your scripting above

Link to comment
Share on other sites

Thanks for the information. Okay, I have made some progress now. First I am able to open the link I want due to arrays and tables. My next problem in the step, is that the Windows File Download messagebox opens. Now my AutoIT seems to go into pause mode. I would like to click the Save in the Windows File Download. After that I would like to be able to input the location to save the file which would be in the next window.

The code I am using is:

; Wait for Alert window, then click on OK

WinWait("File Download", "")

ControlClick("File Download", "", "[CLASS:Button; TEXT:SAVE; Instance:1;]",1)

_IELoadWait ($oIE)

I believe this was part of an example code, in the AutoIT help. Sorry, I wasn't able to put the code in a fancy setup, still learning this forum interface.

This is the issue I was referring to:

getting a reference to it, giving it focus with _IEAction, and then simulating a click on it with Send or ControlSend (this last step required to be simulated because it was stated that a file download dialog appears - if you click on this with the DOM, AutoIt will pause until the dialog is dismissed).

Please see the second example for _IEAction that does just this.

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

This is the issue I was referring to:

Please see the second example for _IEAction that does just this.

Dale

The last bit of the code I was using was from the second IEAction. I have been reviewing this. I do have a question, how do you assign an object when it is a linked image. Do I use ref, img src, id, alt?

$oSubmit = _IEGetObjByName ($oForm, "../Images/zip.gif",0)

I am stuck on this part.

Planets come and go. Stars perish. Matter disperses, coalesces, forms into other patterns, other worlds. Nothing can be eternal. Dr. Who

Link to comment
Share on other sites

The last bit of the code I was using was from the second IEAction. I have been reviewing this. I do have a question, how do you assign an object when it is a linked image. Do I use ref, img src, id, alt?

$oSubmit = _IEGetObjByName ($oForm, "../Images/zip.gif",0)

I am stuck on this part.

Oops bad choice of colors.

$oSubmit = _IEGetObjByName ($oForm,"../Images/zip.gif",0)

Planets come and go. Stars perish. Matter disperses, coalesces, forms into other patterns, other worlds. Nothing can be eternal. Dr. Who

Link to comment
Share on other sites

a "Name" will appear in the HTML source as either NAME=something or ID=something, nothing else. If it has neither, use the appropriate _IE*GetCollection function with an index value.

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

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...