Jump to content

Find the first occurance of an html tag that is visible


Recommended Posts

I'm wanting to grab the text from within a particular classame inside a particular HTML tag.

The _IE* functions work fine for that, but they return a collection of all matches. I'm only interested in the contents of the first match in the portion of the page currently being displayed. If my webpage is, for instance, three screens tall, and the target tag/classname occurs a couple times on each screen, is there a way to know which of the matching items are presently visible on the page?

Or, in a single sentence:

How does one determine which portion of a webpage's HTML is currently being displayed on screen?

Thank you.

Edited by Spiff59
Link to comment
Share on other sites

To the first part of your question, you can iterate through the collection and get the matching item.

As for the second part - thats a Dale question. If you haven't already, have a look at debug bar as that can provide good clues.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

I'm wanting to grab the text from within a particular classame inside a particular HTML tag.

The _IE* functions work fine for that, but they return a collection of all matches. I'm only interested in the contents of the first match in the portion of the page currently being displayed. If my webpage is, for instance, three screens tall, and the target tag/classname occurs a couple times on each screen, is there a way to know which of the matching items are presently visible on the page?

Or, in a single sentence:

How does one determine which portion of a webpage's HTML is currently being displayed on screen?

Thank you.

Read the help file a little closer. When you get collections with _IE* function, you can provide a 0-based index to specify which instance you want. The default is -1, which returns a collection of all instances.

I don't think there is an "OnScreen" property for an element, but you can get the browser window position with WinGetPos(), and get element position with _IEPropertyGet() using "screenX" and "screenY" properties. Then do the math.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I think I'm out of luck. The occurance of the matching tag I want would be whatever one happens to be the first visible on the current screen. I have no way of knowing which occurance that may be.

Edit: I figured it out. Shell.Application.Windows().document.documentelement.scrolltop

Edited by Spiff59
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...