guys. This is a VBS script that opens google, fills a form, and clicks a search button.
set ie = CreateObject("InternetExplorer.Application")
ie.navigate("www.google.com")
ie.visible = true
while ie.readystate <> 4
wscript.sleep 100
WEnd
set fields = ie.document.getelementsbyname("q")
set buttons = ie.document.getelementsbyname("btnG")
fields(0).value = "some query"
buttons(0).click
ie.quit
Sub OnClickSub()
MsgBox "button clicked!", 0
End Sub
Obviously, buttons(0).click fires an onclick event of the button, which I somehow need to catch in my script, and provide it with some processing like launching OnClickSub().
Has anyone got any ideas how this should be done?
Use the GetRef function to obtain a pointer to your event handler and bind it to the onclick event, like this:
buttons(0).onclick = GetRef("OnClickSub")
(Apparently, attachEvent doesn't work when called from outside the web page.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With