Click to See Complete Forum and Search --> : Find Window.......Found Problems
ChrisJackson
Nov 30th, 1999, 01:54 AM
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
Aaron Young
Nov 30th, 1999, 02:57 AM
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.
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 (http://msdn.microsoft.com/workshop/) for more details.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
[This message has been edited by Aaron Young (edited 11-30-1999).]
Compwiz
Nov 30th, 1999, 05:11 AM
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
tyoung@stny.rr.com
ICQ: 15743470 (http://wwp.icq.com/15743470) Add Me (http://wwp.icq.com/scripts/search.dll?to=15743470) ICQ Me (http://wwp.icq.com/scripts/contact.dll?msgto=15743470)
AIM: TomY10 (http://www.aol.com/aim/aim30.html)
PERL, JavaScript and VB Programmer
ChrisJackson
Nov 30th, 1999, 08:06 AM
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
Compwiz
Nov 30th, 1999, 08:50 AM
Where did you get your declaration?
This is what I got out of the API Viewer:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
ChrisJackson
Nov 30th, 1999, 09:53 AM
Compwiz,
Here's where I got the FindWindow Declaration:
http://skyscraper.fortunecity.com/transmission/45/api/f/findwindow.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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.