Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get Internet Eplorer Selected Text?

How to get Internet Eplorer Selected Text?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Utku KAYA
    wrote on last edited by
    #1

    Hi all. I need to get internet expl. selected text to process in my C# application. Any clear help will be appreciated.

    H 1 Reply Last reply
    0
    • U Utku KAYA

      Hi all. I need to get internet expl. selected text to process in my C# application. Any clear help will be appreciated.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Get the IHTMLDocument2 interface from the WebBrowser control (include the Microsoft.mshtml assembly in your project and get it from the WebBrowser.Document property, which may be null), then get the selection property (which may be null). This gets an IHTMLSelectionObject from which you can use the type property to determine the selection type (text, insertion point, control, etc.) and the createRange method to create a suitable object to work with the actual selection (like a TextRange). See the documentation for IHTMLSelectionObject in the MSDN Library for more detailed information).

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      J U 2 Replies Last reply
      0
      • H Heath Stewart

        Get the IHTMLDocument2 interface from the WebBrowser control (include the Microsoft.mshtml assembly in your project and get it from the WebBrowser.Document property, which may be null), then get the selection property (which may be null). This gets an IHTMLSelectionObject from which you can use the type property to determine the selection type (text, insertion point, control, etc.) and the createRange method to create a suitable object to work with the actual selection (like a TextRange). See the documentation for IHTMLSelectionObject in the MSDN Library for more detailed information).

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        Ughhh ugly and messy COM interfaces. Can't wait for Whidbey's managed web browser control. :) The graveyards are filled with indispensible men.

        H 1 Reply Last reply
        0
        • J Judah Gabriel Himango

          Ughhh ugly and messy COM interfaces. Can't wait for Whidbey's managed web browser control. :) The graveyards are filled with indispensible men.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          I haven't had a time to look at it (or eat, or drink, or breathe) lately. Is the WebBrowser control completely managed (inside and out), or is it just a nicer CCW for the existing WebBrowser COM control (wrapping mshtml and providing IHLink and all that jazz)? I know our app would definitely benefit from that, especially when the Microsoft.mshtml.dll assembly is almost 8 MB! :eek:

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          1 Reply Last reply
          0
          • H Heath Stewart

            Get the IHTMLDocument2 interface from the WebBrowser control (include the Microsoft.mshtml assembly in your project and get it from the WebBrowser.Document property, which may be null), then get the selection property (which may be null). This gets an IHTMLSelectionObject from which you can use the type property to determine the selection type (text, insertion point, control, etc.) and the createRange method to create a suitable object to work with the actual selection (like a TextRange). See the documentation for IHTMLSelectionObject in the MSDN Library for more detailed information).

            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

            U Offline
            U Offline
            Utku KAYA
            wrote on last edited by
            #5

            I didnt understand what you tried to tell. What web browser? Do i have to create mine in order to get the selected text? Say there is an instance of ie open , after that my app is run , and typing a hotkey I see the selected text. I want this.

            H 1 Reply Last reply
            0
            • U Utku KAYA

              I didnt understand what you tried to tell. What web browser? Do i have to create mine in order to get the selected text? Say there is an instance of ie open , after that my app is run , and typing a hotkey I see the selected text. I want this.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              "IE" as you call it is nothing more than an application that hosts the WebBrowser control (which hosts MSHTML). Read the documentation for the Internet Explorer SDK. Read information specifically about IHTMLDocument2 and its selection property. If you don't understand how to get the IHTMLDocument2 object, there are plenty of articles here on CP about it. Just search for "WebBrowser" or "IHTMLDocument2".

              -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups