Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying text selection in external app

Status
Not open for further replies.

fishysheep

Programmer
Oct 13, 2001
54
GB
Hi, need to select block of plain text from external app window (IE). tried using getWindowDC and getWindowRect without success. Code so far is:

ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.Navigate("
mouse_event(MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, 20000, 47000, 0, 0) 'move to text
singleClickMouse(3) 'fn to mousedown/up simulate click
SendKeys.Flush()
SendKeys.Sendwait("^C") 'copy

Above works fine, mouse moves to correct co-ords, click three times to select text, and copies.

But what I need to acheive is to be able to copy a block of selected text - so then I tried this:

mouse_event(MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, 20000, 47000, 0, 0) 'move to text
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, 26000, 53000, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
SendKeys.SendWait("^C") 'copy

above does select the text, but nothing is copied. I've tried keybd_event instead of sendkeys.sendwait but that didn't work either. Also tried it without mouse_leftup statement.

Any suggestions grateuflly accepted - still convinced there is a better way to tackle this

ta
 
Since the text you want is displayed in IE, would it be possible for you to find out what file is being displayed by IE, grab that file and then get the text you want?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
if the text was part of html source then I'd be able to do that - since posting the above this text I've realised it's most likely part of an applet. From everything I've read it would seem that applet text is refused by the sytem clipboard, and if I use vb6/net then nothing is copied to the clipboard and .net reports "untrusted".

but, but... if I do a manual highlight and ctrl + c and paste .... I get the data. In the case of MSword I get get the formatting and styles as well - which would seem to imply that it's html. So if msword can read it - why the hell can't .net?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top