Close IE 'Find' with VB6 code
In a WebBrowser, I used IE7's 'Find' to locate a Clickable command.
I can execute the command in Netscape's 'Find' whereas Netscape provides a 'Cancel' option, IE7 does not. Not everyone has Netscape, so I need to Close the IE7 'Find' with VB6 code. Both Netscape and IE7 have the standard form 'Close' in the Caption lineof the 'Find'. VB6 borrows IE's Browser functions, so this must work in IE.
I can brute force find the handle to the 'Find' and close that way, but I would like to be able to issue a one line Close.
The following works in Netscape (in manual testing):
Private Sub FindControlWordAndClick(ControlWord) 'Uses 'Find' text on this Page and puts the focus on that Word in the Browser
intStringFoundAt = 1 'start looking from the top
SendKeys "^F", True: 'DoEvents ' initiate Window's 'Find' pop-up form
SendKeys ControlWord, True: 'DoEvents ' Find the 'ControlWord' text
SendKeys vbCr, True: 'DoEvents ' initiate actual text find
SendKeys "(vbTab)", True: 'DoEvents ' Tab
SendKeys vbCr, True: 'DoEvents ' kill 'find' screen focus is now on the WebBrowser
SendKeys vbCr, True: 'DoEvents ' click to initiate the 'Control' Event
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 ' Release Control. 'KEYEVENTF_KEYUP = &H2 'like the sendkeys but more reliable
Do I need to use the 'DoEvents' to put 'Sleep 100' after each line? Any comments about waiting after each line would be appreciated.
"Good food like good software takes time to prepare"
Try sending the escape key :
about sleep() : it will be better to use it with a good dealing time because deoevents will let another process in the same application to execute but sleep will stop any process in your application only and let the nessery time for IE to do it's work like time to open search box and so on ..
Obvious, so why did I not think of it???
The ESC does close the 'Find' and leaves the find word that I wanted highlighted.
When I send a vbCr in either Netscape 7.2 or IE7 the highlited word flashes.
In Netscape the event is triggered, but in IE7, the event is NOT triggered.
So I still do not have a nice workable solution in IE.
I have a non-clean solution. I have some legacy code that I can reuse that puts the cursor on the x-y location and sends a Click. This is subject to be moved. I will have to the check the version before I trust execution each day.
I don't have any idea why it don't want to work with u !! normally if u have good selected the specified button it will be raised after you send your vbcr ..
Maybe I haven't good understood what u want exactly ; after sending "esc" , what do u want ? remove highlighted location ? send vbcr to this location or what ?
please tell me more about what u want to do ..
About your general method that depends at most in sending keys and moving cursor then click and all that , I think it's not better method , usually u don't know what the user do at the time af proccessing the sending or moving ; what we make us say that you have a propablity of success about 85% only .. i don't know what's your application will do but try to think to make this by different gate , like creatting your owen browser embeded in your application or search in SDKs for solutions.
otherwise try to send with a different method , do u sendkeys vbcr ? try sendkeys "~" or don't wait after sending esc .
By keystoneclimber in forum VB Classic
Last Post: 09-27-2006, 09:33 PM
By Garner in forum VB Classic
Last Post: 05-14-2006, 12:59 AM
By wadheramanish in forum Security
Last Post: 03-07-2006, 07:46 AM
By Al Guten in forum .NET
Last Post: 04-11-2002, 07:48 PM
Last Post: 01-17-2002, 04:32 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL