Jump to content

Specifying X,Y coords while clicking image in IE?


Fur
 Share

Recommended Posts

Been using Dale's awesome IE.au3 UDF to automate things.

I have a form that works via submit when you click a spot on the image. As you are aware, doing so sends the X,Y coordinate the image is clicked as part of the form submission. How do I do this? _IEClickImg() or getting the image object and calling $image.click don't have a means of specifying the coords to pass in to the form.

Can this be done through the OLE interface?

Cheers

Link to comment
Share on other sites

I don't know of anything in the click method for specifying coordianates.

I look around a bit...

Looks to me that .fireEvent is called for... here are some ideas to get you started. I'll assume that your browser is $oIE and the your image map is $oArea

$oEvent = $oIE.document.createEventObject()
$oEvent.clientX = 50
$oEvent.clientY = 300
$oEvent.cancelBubble = True
$oArea.fireEvent("onclick", $oEvent)

I haven't tested this, just adapted an example. The coordinates are "relative to the viewable document area"... it may take a lot of playing to get them to be in a reasonable coordinate system.

Let me know how you fare.

Dale

Been using Dale's awesome IE.au3 UDF to automate things.

I have a form that works via submit when you click a spot on the image. As you are aware, doing so sends the X,Y coordinate the image is clicked as part of the form submission. How do I do this? _IEClickImg() or getting the image object and calling $image.click don't have a means of specifying the coords to pass in to the form.

Can this be done through the OLE interface?

Cheers

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

Well, unfortunately, I've run into another issue. The image doesn't show up as an element in the form! :-(

<html><head><title>Test Form</title></head>
<body>
<form action="http://www.p2pmud.com/form.php" name="testform" method="post">

Input: <input type="text" name="input_value" value="0" size="5" maxlength="8">

<input type="image" src="store10.jpg">

</form>
</body>
</html>

Try to extract it, but there is only one element coming back!

#include <IE.au3>


; Create a browser window and navigate to hotmail
Global $oIE = _IEAttach("Test Form")
if $oIE = 0 Then
     $oIE = _IECreate()
Endif

_IENavigate($oIE, "C:\php5\shop.html")


Local $o_form = $oIE.document.forms.item(0)
Local $elems = $o_form.elements
ConsoleWrite("Num elements " & $elems.length & @LF)

Exit
Link to comment
Share on other sites

I've never been able to find out why, but there are some elements that you would expect to be in the form element collection that are not part of it for some reason. It is aparently implemented inconsistently accross browsers.

In this case, you need to select the object from the collection of all document elements using:

_IETagNameAllGetCollection($oIE)

or

_IETagNameGetCollection($oIE, "input")

You can then either reference them by item number ( .item($n) ) or you can loop through the collection with a For... In... Next loop and check attributes to find a match (like .src )

Dale

Edit: fixed typos

Well, unfortunately, I've run into another issue. The image doesn't show up as an element in the form! :-(

<html><head><title>Test Form</title></head>
<body>
<form action="http://www.p2pmud.com/form.php" name="testform" method="post">

Input: <input type="text" name="input_value" value="0" size="5" maxlength="8">

<input type="image" src="store10.jpg">

</form>
</body>
</html>

Try to extract it, but there is only one element coming back!

#include <IE.au3>
; Create a browser window and navigate to hotmail
Global $oIE = _IEAttach("Test Form")
if $oIE = 0 Then
     $oIE = _IECreate()
Endif

_IENavigate($oIE, "C:\php5\shop.html")
Local $o_form = $oIE.document.forms.item(0)
Local $elems = $o_form.elements
ConsoleWrite("Num elements " & $elems.length & @LF)

Exit
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

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