| View previous topic :: View next topic |
| Author |
Message |
*Ming* Guest
|
Posted: Wed Mar 10, 2010 5:33 am Post subject: Get element coordinates inside Internet Explorer_Server1 |
|
|
In a Internet Explorer_Server1 control there is a text (or Element) whose position (coordinates) is variable and I want to determine.
Using IWebBrowser2, the Element Info shows as:
Value/InnerText: WordToDetermineCoordinates
OuterHtML: <TD class=title-td>WordToDetermineCoordinates</TD>
Can I get the coordinates using iWeb.ahk functions or is there another method to determine Text Coordinates?
I noticed this thread: http://www.autohotkey.com/forum/topic52688.html, but I dont get anything working.
I'm stuck with this for days now , help will be much appreciated. |
|
| Back to top |
|
 |
link4u Guest
|
|
| Back to top |
|
 |
*Ming* Guest
|
Posted: Fri Mar 12, 2010 8:00 pm Post subject: |
|
|
Thanks for the link.
The answer is surely there... but invisible to me
I know
| Code: | COM_Invoke(pelt, "outerHTML") = "<TD class=title-td>WordToDetermineCoordinates</TD>"
COM_Invoke(pelt, "outerText") = "WordToDetermineCoordinates" |
Also hWnd is known, thus pwin, but then things get crazy, among other things because I am clueless about where those "functions" come from (like "src", "tagName"...etc), and I am afraid that I'll need different "functions" for inverting the equation and get t :=COM_Invoke(pbrt, "top")
This is very difficult to me. I even dont know where to get documented...and the script is not commented ..
Please help with this |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Fri Mar 12, 2010 8:41 pm Post subject: |
|
|
Here's a quick example ( using AHKL & COM_L ): | Code: | If !pWin := IEGet( "Google" ).document.parentWindow { ; get window object
MsgBox, No Google Page Exists!
Return
}
element := pWin.document.all.btnG ; get element object (Search Google)
pbrt := element.getBoundingClientRect() ; get element rectagle object
MsgBox, 0, Google Search button, % "Left: " pbrt.left + pWin.screenLeft ; left side of element rectagle + left side of screen
. "`nTop: " pbrt.top + pWin.screenTop
. "`nRight: " pbrt.right + pWin.screenLeft
. "`nBottom: " pbrt.bottom + pWin.screenTop
Return
IEGet( Name="" ) { ; get web browser object
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := Name="New Tab" ? "about:Tabs" : RegExReplace( Name," - (Windows|Microsoft) Internet Explorer" )
Loop, % ( oShell := COM_CreateObject( "Shell.Application" ) ).Windows.Count
If pweb := oShell.Windows( A_Index-1 )
If ( pweb.LocationName=Name && InStr( pweb.FullName, "iexplore.exe" ) )
Return, pweb
} |
**NOTE** - this is based on Sean's work from the link in the second post _________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Fri Mar 12, 2010 9:58 pm Post subject: |
|
|
what really is the benifet of getting the coordinates? _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Fri Mar 12, 2010 10:06 pm Post subject: |
|
|
Well, outside of outlining the element, you could use the coordinates along with MouseClick to click the element . _________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Sat Mar 13, 2010 4:31 am Post subject: |
|
|
| jethrow wrote: | Well, outside of outlining the element, you could use the coordinates along with MouseClick to click the element . | and what do we thing the benifet over the click method is? _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Sat Mar 13, 2010 7:48 am Post subject: |
|
|
| tank wrote: | | and what do we thing the benifet over the click method is? | None that I'm aware of - but it would be an option . _________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Sat Mar 13, 2010 3:32 pm Post subject: |
|
|
I suppose my point is why go thru all the trouble to get coordinates when you can just use the click method and skip the complicated steps of getting the coordinates _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
*Ming* Guest
|
Posted: Tue Mar 16, 2010 9:24 pm Post subject: |
|
|
Hey Jethrow, thank you so much for your reply, it helped me noticing pWin.document.all.btnG, which points out that I do not need to use the outer html, but to find the element name.
With IWebBrowser2 (big thanks to Tank, jethrow (again) and sinkfaze), I could find the element ID (was not easy for this one, just 1 pixel thick hidden line). Then, because I am a total noob about COM, I only managed to modify Sean's script (big thanks to him also) the minimum to make it get the coordinates.
| Quote: | | I suppose my point is why go thru all the trouble to get coordinates when you can just use the click method and skip the complicated steps of getting the coordinates |
You are generally right (of course), but I needed to click on a specific position, unknowing which element will be placed at it. So just doing ControlClick eases thing a lot for me in this case.
Babylon is the application I am trying to automate.
What I achieved is how to click on the dictionary's entries in the Sidebar. But now I found that I can directly get the Dictionary's Headers Element id in the main pane, and that they are detected even if they are not visible (cause you have to scroll down/up).
So now I am trying, without luck, to: 1st detect those elements on the main page and 2nd to navigate to them (or click on them).
As I said, this is quite difficult for me, so I may eventually give up and be content with what I already got working. |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Tue Mar 16, 2010 11:51 pm Post subject: |
|
|
| *Ming* wrote: | | So now I am trying, without luck, to ... | Have you tried reading that link under tank's posts? _________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
|