Monday, August 15, 2011

it work

all this to replace this command in vbscript:
flef.onkeypress = getref("Checklef")
in visual studio 2010

left click on my project (visual studio 2010) (from vbscript)
add reference
microsoft html object library

my oie (internet explorer object):

        Dim OIE As Object
        OIE = CreateObject("InternetExplorer.Application")


my frames:

        '=== object used to write in a frame with writeln
        flef = oie.document.frames("left").document
        fmid = oie.document.frames("middle").document
        fbot = oie.document.frames("bottom").document


my event definition when i define all my buttons:
(wich i can place anywhere now, as the button name is returned)
(new limitation: i cannot name two button with same name in differents frames)
   AddHandler CType(flef, mshtml.HTMLDocumentEvents2_Event).onclick, AddressOf butcli_onclick

and finally my new fonction that will display (as a test) the type and name of the button:

    Private Function butcli_onclick(ByVal e As mshtml.IHTMLEventObj) As Boolean


        'For Each HTMLEle In flef.getElementsByTagName("input")
        '    str01 = LCase(HTMLEle.getAttribute("name"))
        '    str02 = LCase(HTMLEle.getAttribute("type"))
        System.Console.Write("button clicked: " & e.srcElement.tagName.ToString() & vbCrLf)
        System.Console.Write("button clicked: " & e.srcElement.className.ToString() & vbCrLf)


    End Function


strangely, the "classname" is the name of the button that was pressed in internet explorer

also i hate when poeple does not state their imports:

Imports System
Imports System.Xml
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Reflection
'Imports System.Runtime.InteropServices
Imports System.Threading
Imports System.Diagnostics





No comments:

Post a Comment