Form focus issues

bsteiner0385

Member
Joined
Jul 23, 2007
Messages
10
Programming Experience
Beginner
I developed a program that pulls up a search webpage and copies the text. The problem is on slower computers than mine, the timing is off. I have added pauses and such, but this doesnt always help the issue. Would like to have a msgbox pop up asking if the page is loaded. If the page is loaded you click ok/yes and then it copies the text... my problem is focus... The message box never comes into focus (the window is opened maximizedfocus) and if i bring it into focus when you click ok/yes it brings the form into focus instead of the window to be copied. any ideas??? Very much appreciated!!!!
 
I think that the approach you are using to copy the text from a webpage is a bit off. Rather than interacting with another program to copy text, you should try using the web browser control. I think there are a couple of ways to pull text off of a webpage, using timing and keystrokes is not an ideal method.

Maybe if you could provide some background on what you are trying to accomplish another solution could be suggested.
 
Would like to have a msgbox pop up asking if the page is loaded. If the page is loaded you click ok/yes and then it copies the text...

Add a Microsoft WebBrowser Com component and add you code in the event handlers.

For eg, I think you may use the following event

VB.NET:
AxWebBrowser1_DocumentComplete
 
what it does

The program allows you to type in an address, city, state, zip, and type of business. It then pulls up a yelow pages site with all businesses in that category within 3 miles of the address. Basically Compiles a url string with all the info and opens a browser to that page. Then copies all the text on that page, and filters and formats it. So basically I would want to open the page wait for it to complete, copy the text to the clipboard, and then the program already works fine with the rest of the process... I will research the web control... still a little new to .net... If you have any ideas let me know... thanks for your help
 
also...

-deleted, I answered this part of my question... Got the axwebcontrol... cant find documentcomplete....
 
Last edited:
ok dumb question

alright... I see why that was not the most intelligent question... Alright... so I have the axwebcontrol... i have the documentcomplete event handler... the only way i could find to select all and copy the text was to send mouse clicks and cursor movement... id rather not do this if possible... When you right click it gives you the select all function as part of the list... so i am sure there is already a function written to do this... the axwebbrowser doesnt have a select all text that i have seen... can you point me in the right direction... For future references.. if I ask a dumb question at least pointing out that I asked a dumb question would be better than not responding... I really appreciate future help... Dont mind criticism...
 
If this is the same class I am thinking of, then you can access the Document property. You'll have to cast it to an IHTMLDocument2 interface. This will get you access to the raw HTML. But if all you are doing is pulling out specific pieces of data from an html page then you could probably do it a different way. Let me write up a quick sample later tonight.
 
html versus text on page

If you are going to write up a quick sample that would be great... if there is a quick way to kill all the html tags then that is good, but all i really want is the text on the loaded page... like you went to the page hit ctrl+a and then ctrl+c and pasted it into notepad... I have some code generated already to work through the strings and only pull data that is good... Temporary fix to the problem was to use mouse events... but it doesnt work on all computers due to speed issues... THANK YOU VERY MUCH FOR YOUR HELP!!!
 
Ok. So I found a HTML Tag Removing class that a person wrote on The Code Project. You can look at the source here. I changed the Long variables to Integer because using Option Explicit, would generate errors. You can then use the following code.

VB.NET:
        Dim httpClient As New Net.WebClient
        Dim httpData() As Byte = httpClient.DownloadData("http://www.yahoo.com/")
        Dim HTMLCode As String = System.Text.Encoding.ASCII.GetString(httpData)
        Dim HTMLText As String = Extractor.Extract(HTMLCode)

HTMLText will contain the text from the page. This will be roughly equivilant to what you have now. I say roughly, because you'll likely have extra linebreaks that you'll have to deal with.

Let me know if it works out.
 
Ah Ha!!!

Alright... so i figured out a method with the AXWebbrowser... Did a little more research and I found these commands... for future uses this was two lines of code... and I had trouble finding this anywhere... finally adjusted some menu coding for a custom web browser and got to what i wanted...

AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_SELECTALL,_ SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)
AxWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_COPY,_
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

Thought you might be able to use this for future posts... thank you very much for your help!!!
 
Back
Top