 |
 |

04-03-2003, 07:59 PM
|
|
Regular
|
|
Join Date: Feb 2003
Location: TX
Posts: 53
|
|
SendMessage Problems
|
I've written a little program that navigates around the web for you (not particularly useful, but I'm just using it to learn) using a webcontrol. I want to run it in the background, when it wouldn't have focus, and I'd be doing other things. I've found the sendmessage and findwindow APIs, and the findwindow seems to work. My problem seems to be both the FindWindowEx (which always returns 0) and the sendmessage(which has a type mismatch error I can't seem to get rid of) All this code should do is tab through the page.
Code:
Dim mWnd As Long
mWnd = FindWindow(vbNullString, "Title")
mWnd = FindWindowEx(mWnd, 0&, "Internet Explorer_Server", vbNullString)
do
If WebBrowser1.Busy = False Then
SendMessage mWnd, Val(vbKeyTab), 1, ByVal vbNullString
DoEvents
else
DoEvents
end if
while bRunning=True
|
|

04-04-2003, 04:47 AM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
If the webbrowser is inside your application (the browser control) which window are you trying to find?
|
|

04-05-2003, 06:47 AM
|
|
Regular
|
|
Join Date: Feb 2003
Location: TX
Posts: 53
|
|
|
Well, I want the program to run in the background, are there any other ways to send keys to the application? I've tried sendkey, but that sends characters to whatever the frontmost window is.
|
|

04-05-2003, 09:28 AM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
Why are you bothering with all that FindWindow stuff when the browser control has a .hWnd property?
And yes, there is a more elegant solution of browsing through pages without user interaction. It is called Document Object Model (DOM). There are many examples here on the forum.
|
|

04-05-2003, 02:03 PM
|
|
Regular
|
|
Join Date: Feb 2003
Location: TX
Posts: 53
|
|
Quote: Originally Posted by Squirm Why are you bothering with all that FindWindow stuff when the browser control has a .hWnd property?
And yes, there is a more elegant solution of browsing through pages without user interaction. It is called Document Object Model (DOM). There are many examples here on the forum.
ah...that actually hadn't occurred to me, even though I'd been using the .hWnd to check the value i returned from findwindow....
I'm gonna go check out that DOM thing right now! Thanks.
|
|

04-05-2003, 03:59 PM
|
|
Regular
|
|
Join Date: Feb 2003
Location: TX
Posts: 53
|
|
|
Thanks for all your help guys, it's working great now! and in the background to boot. I ended up just doing a navigate2, so i was making it 1000x as hard as it had to be.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|