Results 1 to 4 of 4

Thread: Raising JavaScript Event from VB6

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Location
    St. Louis
    Posts
    25

    Raising JavaScript Event from VB6

    I used WebBrower to navigate and have a Web page visible which has JavaScript MouseClick events. I want to be able to trigger these events from VB6 code. Can this be done.

    The thread.php?t=368471 is similar. That is:

    VB Code:
    1. Private Sub Control_MouseMove(ByVal sender As Object, _
    2.           ByVal e As System.Windows.Forms.MouseEventArgs) Handles mouseMove,  Button1.MouseMove.
    3.    Console.WriteLine("Control_MouseMove: " & DirectCast(sender, Control).Name)
    4. End Sub


    What do I use as the 'Panel1', 'sender' and 'Control' equivalent from the JavaScript.


    Good software like good food takes time to prepare.
    Winnie-the-Pough (sic)

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Raising JavaScript Event from VB6

    You probably need to get familiar with DOM handling via VB6. When you push F2, you see the Object Browser. You can take a look into the WebBrowser components that are provided, these allow you to create new elements and possibly to trigger events as well; for the least you should be able to add custom code into the page, meaning you can add more JavaScript.

    It might be hard though, so you'll need patience and a good bit of reading on the forums and via Google I don't have any of this in fresh memory so I can't help more than this.

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Raising JavaScript Event from VB6

    This seems like .NET code... If so, you'll get much better responce in the forums .NET section.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Location
    St. Louis
    Posts
    25

    Re: Raising JavaScript Event from VB6

    While searching for information on DOM as suggested in one of the above responses, I found this:
    http://keyword.netscape.com/ns/boom...?query=ms759132
    which explains clone Method
    Clones a copy of the current IXMLDOMSelection, with the same position and context.

    Code:

    Dim xmlDoc As New Msxml2.DOMDocument30 Dim xpath As IXMLDOMSelection Dim xpath2 As IXMLDOMSelection Dim temp1 As IXMLDOMNode Dim temp2 As IXMLDOMNode xmlDoc.loadXML ("<root><elem1>Hello</elem1><elem2>World!</elem2></root>") If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else ' Create an XMLDOMSelection object from selected nodes. Set xpath = xmlDoc.selectNodes("root/elem1") ' Cache the XPath expression and context. xpath.expr = "root/elem1" Set xpath.context = xmlDoc ' Clone the XMLDOMSelection object. Set xpath2 = xpath.Clone() Set temp1 = xpath.peekNode() ' temp1 == <elem1/> MsgBox("temp1: " & temp1.xml) Set temp2 = xpath2.peekNode() ' temp2 == <elem1/> MsgBox("temp2: " & temp2.xml) ' Note that position and context are maintained. End If



    It appears to me that this allows me to fetch the value from the screen DOM that is written by the JavaScript of the xmlDoc.loadXML. I had been using innerbody for this purpose. ( I assume I need to include more of the original JavaScript in my VB6 clone, as the clone needs to know the other properties, e.g. location, etc. )

    I find no examples of being able to Poke text using this or similar method. Is that possible? I am not asking for code, I want a simple Yes or No on the Poke, unless the problem is more involved and someone has a ready solution.

    My original question was to be able to simulate a click without having to locate the positon on the screen.

    I can find the line in the JavaScript that initiates the 'onKeyUp=..."
    Can I somehow simulate that with a variation of the clone Method?

    I need more help on this last question than a Yes Or No.


    Thanks

    Winnie-the-Pough

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