dcsimg
Results 1 to 10 of 10

Thread: Perform double click on html element, vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    3

    Perform double click on html element, vb6

    I want to perform double click on an html element. I can click once, but cant double. I tried to move mouse on element but couldnt find coordinates.

    Code:
    ...
    IE.Document.GetElementById(An & "q8").focus  
    IE.Document.GetElementById(An & "q8").dblclick ' not working on hmtl 
    ...
    I can't add,change etc html codes. So i can't add or change events, attributes. I need to doubleclick on element directly, maybe mousemove and click or something like that. Double click action selects a value from a popup list, and set it to a inputbox. Keystrokes not working. Client side changes are not applied. I tried to change input value, but when another element's value changes first one returns to original value.

    Any idea? I'm realy stuck here

    (vb6 and ie8+)

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,073

    Re: Perform double click on html element, vb6

    What is the element?


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,723

    Re: Perform double click on html element, vb6

    Have you considered the fireEvent() method?

    Code:
    <HTML>
    <HEAD>
    <TITLE>Example of ondblclick Event</TITLE>
    <SCRIPT LANGUAGE="VBScript">
    'This would be code in your VB6 host program:
    Private Sub btnClickMe_onclick()
        lstStuff.fireEvent "ondblclick"
    End Sub
    </SCRIPT>
    </HEAD>
    <BODY>
    <!-- This button represents some action in your VB6 host program: -->
    <BUTTON ID=btnClickMe>Choose one below then Click Me</BUTTON><BR><BR>
    
    <SELECT ID=lstStuff SIZE=5
    ondblclick="txtCopy.value=lstStuff.children(lstStuff.selectedIndex).innerText">
    <OPTION VALUE="1">This
    <OPTION VALUE="2">That
    <OPTION VALUE="3" SELECTED>The other thing
    <OPTION VALUE="4">More
    <OPTION VALUE="5">Still more
    </SELECT><BR>
    <INPUT TYPE=text ID=txtCopy>
    </BODY>
    </HTML>

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,723

    Re: Perform double click on html element, vb6

    I guess this was a drive-by single use account. I see he's crossposted to several sites and probably never came back here.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    3

    Re: Perform double click on html element, vb6

    im here :P, i asked in 2 forums because this issue is not reguler one.

    i cant use events, page coded fully jscript and serverside, maybe I failed, i'll try again. I have to say, element names changing every time popup appairs, only first 4 digits are constant (i choose by the innertext value).

    Element type is div. If i could find element screen position every time, i was able to send double-click action.

    With dblclicking, some value is sent from server to an input box on main page. When i write that input's innertext or value manually, it seems that value is changed, but serverside it is not changed. I mean, i can only perform a double click action on element.

    I searched the web a lot but never found a solution for this issue exactly.
    Last edited by alaslar; Aug 25th, 2015 at 01:35 AM.

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,073

    Re: Perform double click on html element, vb6

    I don't see that double click is supported for the MSHTML.HTMLDivElement unless you know something else.

    There is an MSHTML.HTMLDivPosition but I have never used it


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,723

    Re: Perform double click on html element, vb6

    Works fine, as already suggested earlier.


    sample.htm
    Code:
    <HTML>
     <BODY>
      <DIV ID=someDIV
       ondblclick="alert('I have been double-clicked!')"
      >The DIV text</DIV>
     </BODY>
    </HTML>
    Form1.frm
    Code:
    Option Explicit
    
    Private Document As MSHTML.HTMLDocument
    
    Private Sub Form_Load()
        WebBrowser1.Navigate2 "file://" & App.Path & "/sample.htm"
    End Sub
    
    Private Sub mnuDblclickit_Click()
        Document.All("someDIV").FireEvent "ondblclick"
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        If pDisp Is WebBrowser1.Application Then
            Set Document = WebBrowser1.Document
            mnuDblclickit.Enabled = True
        End If
    End Sub
    Or more laboriously:

    Code:
    Private Sub mnuDblclickit_Click()
        Dim DIV As MSHTML.HTMLDivElement
    
        Set DIV = Document.All("someDIV")
        DIV.FireEvent "ondblclick"
    End Sub

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,073

    Re: Perform double click on html element, vb6

    Nice, dil, but what if HTML has no code like

    Code:
    <DIV ID=someDIV ondblclick="alert('I have been double-clicked!')"
    >The DIV text
    </DIV>
    OP stated:

    I can't add,change etc html codes. So i can't add or change events, attributes.
    Last edited by jmsrickland; Aug 25th, 2015 at 01:08 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,723

    Re: Perform double click on html element, vb6

    Er, I think his whole point is that his target page already has script to handle this event and he is asking how to trigger it from within the VB6 program. The event handler in my examples just represents the page's script.

    If he is trying to do something else then I'm not sure what it might be.

  10. #10

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    3

    Re: Perform double click on html element, vb6

    It is done. I can get element's coordinates after a few tries.

    For ex. top of element is:

    mX = IE.Document.GetElementById("id").Offsetparent.Offsetparent.Offsetparent.offsettop + IE.Document.GetElementById("id").Offsetparent.Offsetparent.offsettop + IE.Document.GetElementById("id").Offsetparent.offsettop + IE.Document.GetElementById("id").offsettop - IE.Document.documentElement.scrollTop

    For left:

    mY = IE.Document.GetElementById("id").Offsetparent.Offsetparent.Offsetparent.offsetleft + IE.Document.GetElementById("id").Offsetparent.Offsetparent.offsetleft + IE.Document.GetElementById("id").Offsetparent.offsetleft + IE.Document.GetElementById("id").offsetleft

    After that, mouse move to (mY + 30, mX+ 30), and perform multiple left clicks.

    Thanks for your attention, and good days.
    Last edited by alaslar; Feb 17th, 2016 at 03:50 AM.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width