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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys class

Status
Not open for further replies.

Shiloy

Programmer
Mar 23, 2007
4
US
I want to do a CTL "C" command in my VB.Net app. I want to highlight text from any where, word, IE, Notepad, Applications, where ever I may be, then run a .Net app that does the copy and puts it in the clipboard. The app then uses what is in the clipboard as a parameter to another app and opens that app and does a search on that parameter.

My app works just using the clipboard class when I do a manual CTRL "C" but I am not sure how to handle the SendKeys class to get it to work. It should do a copy and which then places in the clipboard so I can retrieve.

Sendkeys.send("^(C)") is supposed to do a copy but I think I need more.

Any ideas or is there another way to do what I need to do.

Thank You
 
I would say not to use sendkeys. Too much room for error. Instead, I would recommend using the windows api. From this you do not even need the window focused or in view. It can be minimized and you can get at the text. With regard to sendkeys, some apps recognize an automated copy/paste and will not allow it. IE being one of them. The best way to get the text from IE is using the htmldocument innertext and/or innerhtml. I posted code a ways back here to a gal looking to do web screen-scraping. Lookup user32.dll for the Windows API stuff. A little more difficult to code, but well worth it in the end. CIAO~~~
 
Thanks arznrchrd. I might need a little more direction. I cannot seem to find the code you posted previously on screen scraping.
 
Odd, seems to have been taken off. See below for IE screen scraping:

Navigate to Site:
Webmycontrol.Navigate(New System.Uri("
If the site has frames, you want to grab the text from the correct frame:
Dim hElement As HtmlElement = Nothing
Dim hElement2 As HtmlElement = Nothing

hElement = Webmycontrol.Document.Window.Frames(0).Document.GetElementById("your element id")
hElement.SetAttribute("value", "your attribute") 'used for a dropdown box on the site

hElement2 = Webmycontrol.Document.Window.Frames(0).Document.GetElementById("button id")
hElement2.InvokeMember("click") ' used to click a button on a site

If no frames:
webmycontrol.document.innertext

If frames:
Webmycontrol.Document.Window.Frames(2).Document.Body.InnerText
 

I am coding a VB.Net windows application not a web application so I need to do some more searching.

thanks for the time you took to help me out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top