Results 1 to 15 of 15

Thread: How to dedect if mouse is pressed on Webbrowser?

  1. #1

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    How to dedect if mouse is pressed on Webbrowser?

    How to dedect if mouse or key is pressed on Webbrowser?
    There's no such thing like Webbrowser1_Click or Webbrowser1_MouseDown

    I need to start a countdown timer every time user clicks on the webbrowser
    So it'd show idle time or something

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to dedect if mouse is pressed on Webbrowser?

    add a reference to the HTML Object library

    VB Code:
    1. Dim WithEvents HTMLDOC As HTMLDocument
    2.  
    3.  
    4.  
    5. Private Sub Form_Load()
    6.     WebBrowser1.Navigate "www.vbforums.com"
    7. End Sub
    8.  
    9. Private Function HTMLDOC_onclick() As Boolean
    10.     Debug.Print "CLICK!"
    11. End Function
    12.  
    13. Private Sub HTMLDOC_onmousedown()
    14.     Debug.Print "MOUSEDOWN!"
    15. End Sub
    16.  
    17. Private Sub HTMLDOC_onmouseup()
    18.     Debug.Print "MOUSEUP!"
    19. End Sub
    20.  
    21. Private Function HTMLDOC_onmousewheel() As Boolean
    22.     Debug.Print "MOUSEWHEEL!"
    23. End Function
    24.  
    25. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    26.     If Not WebBrowser1.Document Is Nothing Then
    27.         Set HTMLDOC = WebBrowser1.Document
    28.     End If
    29. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    Re: How to dedect if mouse is pressed on Webbrowser?

    It detects it when I create new project and test the code on it.
    But if I try the code on my existing project, it won't work.
    What could block/interrupt this code?

  4. #4
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to dedect if mouse is pressed on Webbrowser?

    actually not sure what would stop it from working?!??
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    Re: How to dedect if mouse is pressed on Webbrowser?

    But is it possible, to create some area with API or something, and detect, if mouse is clicked there?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: How to dedect if mouse is pressed on Webbrowser?

    Quote Originally Posted by Sannu
    But is it possible, to create some area with API or something, and detect, if mouse is clicked there?
    All controls have both a mouse down and click event if that is what you mean.

  7. #7
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to dedect if mouse is pressed on Webbrowser?

    actually Hack, the webbrowser control doesnt...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    Re: How to dedect if mouse is pressed on Webbrowser?

    Yes, that's what i mean..

  9. #9

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    Re: How to dedect if mouse is pressed on Webbrowser?

    Bump

  10. #10
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    Re: How to dedect if mouse is pressed on Webbrowser?

    Well If you want to get all the clicks of all the webbrowser then you have to do like a download software "Reget Delux" does, it installs a .dll as we installs Flash Plugin.

    So you have to develop such plugin so you can get what ever happneing at WebBrowser even at iexplore.exe
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

  11. #11

    Thread Starter
    Junior Member Sannu's Avatar
    Join Date
    Nov 2005
    Posts
    21

    Re: How to dedect if mouse is pressed on Webbrowser?

    no you can't just understand
    I have a form
    I have a wb on it
    I want to capture all clicks on webbrowser

  12. #12
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    Re: How to dedect if mouse is pressed on Webbrowser?

    As i told you to do so, you have to make a IE plugin that will capture all clicks and the appropriate function (defined by you) will be called

    other Relatively Easy way to accomplish goal is

    When ever the page is loded then add some JavaScript Using InnerHTML property than would be like OnClick="Javascript:document.location(sannu://click)
    and capture it at navigate event
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

  13. #13
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to dedect if mouse is pressed on Webbrowser?

    the code I posted should work.. if it worked in its own project.. then something u have going on is stopping it. keep playing.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  14. #14
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    Re: How to dedect if mouse is pressed on Webbrowser?

    Quote Originally Posted by Static
    add a reference to the HTML Object library

    VB Code:
    1. Dim WithEvents HTMLDOC As HTMLDocument
    2.  
    3.  
    4.  
    5. Private Sub Form_Load()
    6.     WebBrowser1.Navigate "www.vbforums.com"
    7. End Sub
    8.  
    9. Private Function HTMLDOC_onclick() As Boolean
    10.     Debug.Print "CLICK!"
    11. End Function
    12.  
    13. Private Sub HTMLDOC_onmousedown()
    14.     Debug.Print "MOUSEDOWN!"
    15. End Sub
    16.  
    17. Private Sub HTMLDOC_onmouseup()
    18.     Debug.Print "MOUSEUP!"
    19. End Sub
    20.  
    21. Private Function HTMLDOC_onmousewheel() As Boolean
    22.     Debug.Print "MOUSEWHEEL!"
    23. End Function
    24.  
    25. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    26.     If Not WebBrowser1.Document Is Nothing Then
    27.         Set HTMLDOC = WebBrowser1.Document
    28.     End If
    29. End Sub
    Ya it is working perfectly...

    But if he Wants to do by api he might be asking for Hooking
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

  15. #15
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: How to dedect if mouse is pressed on Webbrowser?

    Quote Originally Posted by Vishalgiri
    Ya it is working perfectly...

    But if he Wants to do by api he might be asking for Hooking
    API is not always the best way
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width