Close IE 'Find' with VB6 code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Close IE 'Find' with VB6 code

  1. #1
    Join Date
    Jul 2004
    Location
    St. Louis, Mo
    Posts
    111

    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
    End Sub

    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"
    Winnie-the-Pough

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Try sending the escape key :

    SendKeys "{ESC}"

    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 ..
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Jul 2004
    Location
    St. Louis, Mo
    Posts
    111
    thanks: Amahdy
    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 would still like to be able to send a Post in the Applications syntax, but that is not easily decode from the obscured and hidden JavaScript. I can view most of the CSS and JS, but some parts are not visible.

    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.

    Winnie-the-Pough

  4. #4
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    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.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #5
    Join Date
    Jul 2004
    Location
    St. Louis, Mo
    Posts
    111
    Amahdy:
    When I 'esc', the 'Find' disappears and leaves the selection that was found highlighted. I expect that when I send a Left Click or vbCr that the JavaScript event will occur as it does in Netscape but not in IE, which is where I borrowed the WebBrowser. Nominally, if I were to manually select the location, I could Left Click or CR and the event would occur.

    Winnir-the-Pough

  6. #6
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    you send cr >> your javascript occur or not yours ?
    if it's yours so find why javascript problem ... if it's not yours try [only a test] sending space , sometimes it's equivalent . but generally I still don't know why cr doesn't work ... maybe IE lost it's focus after sending "esc" ?
    otherwise try to send with a different method , do u sendkeys vbcr ? try sendkeys "~" or don't wait after sending esc .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  7. #7
    Join Date
    Jul 2004
    Location
    St. Louis, Mo
    Posts
    111
    Amahdy: Thanks,
    The comercial ( not mine ) web application uploads the JavaScript to my computer after I logon. The IE did not lose focus whereas the target blinks when I send the CR, but the JavaScript does not initiate its response. The JavaScript is supposed to change change modes. Repeated CRs still responds with blinks!!! I will try your "~".

    Winnie-the-Pough

Similar Threads

  1. Shortest VB6 HTML scrape code
    By keystoneclimber in forum VB Classic
    Replies: 1
    Last Post: 09-27-2006, 08:33 PM
  2. open & close EXCEL with VB6
    By Garner in forum VB Classic
    Replies: 18
    Last Post: 05-13-2006, 11:59 PM
  3. password protect my vb6 code
    By wadheramanish in forum Security
    Replies: 1
    Last Post: 03-07-2006, 06:46 AM
  4. Replies: 0
    Last Post: 04-11-2002, 06:48 PM
  5. Replies: 17
    Last Post: 01-17-2002, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center