-
Thanks to Aaron, I was finally able to get to the source code using the WebBrowser Control. My problem now is that I need my program to delay execution until the Notepad window appears because it takes a few seconds to show up on the screen.
I tried using:
hwnd = FindWindow(CLng(0), strtemp)
Do Until hwnd <> 0
Sleep 500 ' pause for half a second
hwnd = FindWindow(CLng(0), strtemp)
Loop
But the program never found the Window, and just kept sleeping!
Does anybody know of a way to pause the program's execution until Notepad finishes loading without setting up a "dummy" do-nothing loop? - DoEvents didn't work. :=(
Second question:
I am trying to use the "AppActivate Notepad" command to activate the Notepad window, but this command works from LEFT to RIGHT and Notepad's title bar places the file name first. E.g. "login(1) - Notepad".
Does anyone know how to get around this?
P.S. Of course, if there was a "save source" command, both of the above problems would instantly vanish! Does something like this exist?
Thanks
Chris
-
I couldn't find anything like SaveSource, but I did find the InnerHTML Property, and if you use this with the HTML Object - Webbrowser1.Document.All(1) you can get all the HTML between the HTML Tags, eg.
Code:
Private Sub Command1_Click()
Dim iFile As Integer
iFile = FreeFile
Open "C:\Saved.htm" For Output As iFile
Print #iFile, "<html>" & WebBrowser1.Document.All(1).InnerHtml & "</html>"
Close iFile
End Sub
Checkout the MSDN Online Web Workshop for more details.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
[This message has been edited by Aaron Young (edited 11-30-1999).]
-
I just noticed:
When declaring the FindWindow API, you will notice that is says: lpClassName As String. Therefore, you should use the vbNullString and not a Long.
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Thanks for your replies Young-sters - Aaron and Tom, that is. (I couldn't resist.)
Tom, a quick point of clarification. The FindWindows API that I reviewed specified lpClassName As Any not lpClassName As String.
Aaron, FYI, I got an error when I tried to use the InnerHTML code example you provided.
Since trying to figure this problem out, I've discovered that you can get different results when you use different methods to retrieve the HTML source code of a web page. For example, if someone right-clicked and selected "View Source", the code displayed would be different from that returned using the view-source: statement on the particular web page that I've been working with.
It seems that the ExecWB statement could have done the trick, but I couldn't get it to automatically complete the steps to save the file.
It seems my only solution is to use the Windows API to mimic right-clicking, selecting "View Source" and then saving the Notepad file.
Again,
Thanks for all of the replies.
Chris
------------------
CJ
-
Where did you get your declaration?
This is what I got out of the API Viewer:
Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
Compwiz,
Here's where I got the FindWindow Declaration:
http://skyscraper.fortunecity.com/tr...indwindow.html
I also have the API-Guide and noticed that it did use lpClassName As String.
Maybe the above website is incorrect.
All the best.
Chris
------------------
CJ