Use the createRange method of the IHTMLSelectionObject object to return an IHTMLTxtRange object that represents the currently selected text and elements in the active document. Use the createTextRange method of the IHTMLInputTextElement object to return an IHTMLTxtRange object that represents the text range of the desired text input element. Use IHTMLTxtRange::inRange to determin if the cursor is in the input. If so, call IHTMLTxtRange::moveStart and IHTMLTxtRange::moveEnd with the unit parameters set to textedit to retrive the location of the selection.