0

I'm working on a screen reader and till now I was successful to get the whole text of a page in IE. But I have no idea how to get the current visible part of page or to get the current paragraph that is under the cursor in IE.

I don't mean to give me the code, but just to recommend me if there is a way to do it using APIs or similar things.

from what I found I think it’s not doable using Accessibility APIs.

I GREATLY appreciate any ideas and helps.

Bella
  • 3
  • 1

2 Answers2

0

To access the contents of a paragraph when the cursor moves over it you could use javascript:

var oP = document.body.getElementsByTagName('p');
for (var i = 0; i < oP.length; i++) {
    oP[i].onmouseover = function() {
        var content = oP[i].innerHTML;

        // Do whatever you want with content.
    };
}

This will fire the onMouseOver event when cursor moves over a paragraph and you will then be able to read it's content.

Felix Glas
  • 15,065
  • 7
  • 53
  • 82
  • Special thanks snipes83, but your nice code is in javascript. It's ok, I can use it as an extension for IE or FF, but I like to stay away from extensions. I'd like to get paragraph or at least visible part of page from my external application which is in c#. any ideas? – Bella Aug 15 '11 at 13:25
  • What's the problem with JavaScript in IE or FF? – James Johnson Aug 15 '11 at 16:44
  • @James Johnson: Sorry for being a bit unclear. In my screen reader,(that is an external application) I want to get paragraph of the running instance of IE. It can't be done using javascript, since my application is in c#. I have gotten the whole text using "RegisterWindowMessage" and related methods, but getting paragraph can't be done using these methods. Am I wrong? – Bella Aug 15 '11 at 17:50
  • @Bella: It's a WinForms application? C# can be used with both web and windows apps, so for future reference, specify WinForms, WebForms, MVC, etc. – James Johnson Aug 15 '11 at 17:56
  • So sorry for the mistake (I'm currently so busy with this project and was not aware of it), yes it is a windows application. – Bella Aug 15 '11 at 18:14
0

If you're application is a WinForms app, you might want to look into using the Browser control. I'm still a bit unclear about what you're looking for, but I think the browser control is what you'll need.

Here's a similar question that may point you in the right direction:

C# WebBrowser control -- Get Document Elements After AJAX?

Community
  • 1
  • 1
James Johnson
  • 45,496
  • 8
  • 73
  • 110