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+)
Re: Perform double click on html element, vb6
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>
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.
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.
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
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
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.
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.
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. :)