Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > SendMessage Problems


Reply
 
Thread Tools Display Modes
  #1  
Old 04-03-2003, 07:59 PM
Nelda Nelda is offline
Regular
 
Join Date: Feb 2003
Location: TX
Posts: 53
Default 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
Reply With Quote
  #2  
Old 04-04-2003, 04:47 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

If the webbrowser is inside your application (the browser control) which window are you trying to find?
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #3  
Old 04-05-2003, 06:47 AM
Nelda Nelda is offline
Regular
 
Join Date: Feb 2003
Location: TX
Posts: 53
Default

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.
Reply With Quote
  #4  
Old 04-05-2003, 09:28 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

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.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #5  
Old 04-05-2003, 02:03 PM
Nelda Nelda is offline
Regular
 
Join Date: Feb 2003
Location: TX
Posts: 53
Default

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.
Reply With Quote
  #6  
Old 04-05-2003, 03:59 PM
Nelda Nelda is offline
Regular
 
Join Date: Feb 2003
Location: TX
Posts: 53
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending ReturnKey with SendMessage EpcH API 5 03-20-2003 12:31 AM
VB.net API SendMessage MyNuS API 1 12-06-2002 05:49 AM
SendMessage Problems Luber25 API 4 03-12-2002 04:32 PM
How to use SendMessage API pinster API 2 03-12-2002 04:26 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->