AutoHotkey Community

It is currently May 27th, 2012, 5:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: March 10th, 2010, 6:33 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 8:05 am 
Check out Sean's IE HTML Element Spy.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 9:00 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 9:41 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
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

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 10:58 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
what really is the benifet of getting the coordinates?

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 11:06 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Well, outside of outlining the element, you could use the coordinates along with MouseClick to click the element :P .

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2010, 5:31 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
jethrow wrote:
Well, outside of outlining the element, you could use the coordinates along with MouseClick to click the element :P .
and what do we thing the benifet over the click method is?

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2010, 8:48 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
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 :lol: .

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2010, 4:32 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2010, 10:24 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 12:51 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
*Ming* wrote:
So now I am trying, without luck, to ...
Have you tried reading that link under tank's posts?

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, HotkeyStick, rbrtryn, XstatyK and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group