Jump to content

How to click on Image Map in IE


VAG
 Share

Recommended Posts

I am trying to learn how to use the <IE.au3> to navigate a website. In my script, I am able to click on image to link to 2nd page. But when I call the same method to on an image map on 2nd page, it's not working.

Can anyone show me what is the correct method to target on a Image Map?

#include <IE.au3>

TrayTip("AutoIT", "Open Webpage", 3)
$oIE = _IECreate ("[url="http://www.creative.com"]http://www.creative.com[/url]", 0, 1, 1, 1)

TrayTip("AutoIT", "Click on a Image Link [Sound Blaster Button Picture]", 3)
_IEImgClick($oIE, "Sound Blaster", "alt")
If Not @error = 0 Then
ConsoleWriteError("_IEImgClick  error: " & @error & @CRLF)
EndIf
_IELoadWait($oIE)

TrayTip("AutoIT", "Click on a Image Link [Picture Map - Product info]", 3)
_IEFormImageClick($oIE, "Product Info", "alt")
If Not @error = 0 Then
ConsoleWriteError("_IEImgClick  error: " & @error & @CRLF)
EndIf
_IELoadWait($oIE)

; Get the IE window title [For target page verification]
$s_PageTitle = _IEPropertyGet($oIE, "title")
MsgBox("", "Webpage Title", $s_PageTitle)

_IEQuit($oIE)
Link to comment
Share on other sites

So, do you know what an "image map" is? It is a special HTML construct and I don't see on the site you are trying to automate.

Please look at the docs for _IEFormImageClick - you are not using it correctly and it is not what you want.

You should be able to use the same _IEImgClick methods you used of the first 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

OK. I try to correct my code. I will perform a "_IEImgClick" on the 2nd Page directly. I am using "alt" as reference to the "Product Info" button on the image. But then it didn't click on the link and go to the 3rd page. Posted Image

Any suggestion?

#include <IE.au3>

$oIE = _IECreate ("[url="http://sg.creative.com/products/feature.asp?category=1&WT.cg_n=Campaigns&WT.mc_id=11162&utm_source=sg.creative.com&utm_medium=Banner&utm_content=HomepageCatIcon_SoundBlaster&utm_campaign=ProductCatIcon"]http://sg.creative.com/products/feature.asp?category=1&WT.cg_n=Campaigns&WT.mc_id=11162&utm_source=sg.creative.com&utm_medium=Banner&utm_content=HomepageCatIcon_SoundBlaster&utm_campaign=ProductCatIcon[/url]", 0, 1, 1, 1)

_IEImgClick($oIE, "Product Info", "alt")
If Not @error = 0 Then
ConsoleWriteError("_IEImgClick  error: " & @error & @CRLF)
EndIf
_IELoadWait($oIE)

; Get the IE window title [For target page verification]
$s_PageTitle = _IEPropertyGet($oIE, "title")
MsgBox("", "Webpage Title", $s_PageTitle)
Link to comment
Share on other sites

Please, Please look at the output from SciTe and figure this out on your own.

You get the warning message:

--> IE.au3 V2.4-0 Warning from function _IEImgClick, $_IEStatus_NoMatch

"NoMatch" from _IEImgClick

There is no image on that page with alt text of "Product Info"

Please get and use DebugBar if you don't have it and work through examples in the helpfile.

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

Sorry to bother you. But I have been using Debugbar to target on this button. What I get is the "alt" and "coords" and "href" values. I know that I shouldn't use the "herf" value. Actually I have been reading up the help topic on "_IE" for quite some time, but I notice not all sub methods are shown. Maybe my HTML or Javascript is not up to skill.Posted Image

I understand you gets quite alot of posts to reply. If you're not free to reply, can you point me to any similar post on this topic? I will try to study on my own. Thanks.

<AREA shape=RECT alt="Product Info" coords=748,269,845,293 href="/products/product.asp?category=1&subcategory=872&product=17813&utm_source=sg.creative.com&utm_medium=Banner&utm_content=FeaturePg_X-FiTitaniumFCSProductInfo&utm_campaign=FeaturePage">
Edited by VAG
Link to comment
Share on other sites

Your questions and your HTML keep changing.

Please ask a clear focused question.

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

I would like to know how to click on the "Product Info" image link on the following page:

My link

The autoit code I have written so far is:

#include <IE.au3>

$sLink = "sg.creative.com/products/feature.asp?category=1&WT.cg_n=Campaigns&WT.mc_id=11162&utm_source=sg.creative.com&utm_medium=Banner&utm_content=HomepageCatIcon_SoundBlaster&utm_campaign=ProductCatIcon"
$oIE = _IECreate ($sLink)
_IEImgClick($oIE, "Product Info", "alt")
If Not @error = 0 Then
ConsoleWriteError("_IEImgClick  error: " & @error & @CRLF)
EndIf

The return error code indicate the image is not found. How do I reference the clicking action on this spot if the available information from DebugBar is only like this:

<AREA href="/products/product.asp?category=1&subcategory=872&product=17813&utm_source=sg.creative.com&utm_medium=Banner&utm_content=FeaturePg_X-FiTitaniumFCSProductInfo&utm_campaign=FeaturePage" shape=RECT alt="Product Info" coords=748,269,845,293>
Link to comment
Share on other sites

_IEProprtyGet will help you get screen coordinates of the AREA element (_IETagnameGetCollection) and then you can use them with MouseClick.

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

Thank you ver much Dale. I finally have something working.Posted Image Here is my code. Just one more question....I notice the mouse clicking is offset. So does it mean I need to compensat the offset manually to allow it to click on the correct spot?

#include <IE.au3>

$sLink = "sg.creative.com/products/feature.asp?category=1&WT.cg_n=Campaigns&WT.mc_id=11162&utm_source=sg.creative.com&utm_medium=Banner&utm_content=HomepageCatIcon_SoundBlaster&utm_campaign=ProductCatIcon"
$oIE = _IECreate ($sLink)
WinSetState(_IEPropertyGet($oIE, "hwnd"), "", @SW_MAXIMIZE)

$oAREAs = _IETagnameGetCollection($oIE, "AREA")

For $oAREA In $oAREAs 
    If $oAREA.coords="748,269,845,293"  Then
  $iScreenX = _IEPropertyGet($oAREA, "screenx")
  $iScreenY = _IEPropertyGet($oAREA, "screeny")
  $iWidth = _IEPropertyGet($oAREA, "height")
  $iHeight = _IEPropertyGet($oAREA, "width")
  MouseMove($iScreenX + $iWidth/2 , $iScreenY + $iHeight/2)
  MouseClick("left")
EndIf
Next
Edited by VAG
Link to comment
Share on other sites

Coordinate calculation is quite complex and is not consistent accross versions of browsers unfortunately. Suggest you look at the code in IE.au3 and see what it does.

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