Events+JScript+WSH 
Author Message
 Events+JScript+WSH

Hello-

I have some jscript code ( being executed by cscript.exe ) which loads a COM
Object. This object fires events, and I would like to attach a jscript
function to these events. I have successfully attached to events in an HTML
page using the <script for=obj event=env>, but I am not sure how to
implement this if the code is being interpreted by cscript and is not
embedded in a web page. Are there any examples anywhere of using
jscript+events? All of the examples I have found so far appear to be VBS
centric.

Thanks -

John

--
John Dunn

Peak Audio, Inc
www.peakaudio.com



Fri, 07 Jun 2002 03:00:00 GMT  
 Events+JScript+WSH

See the doc's for the WScript.CreateObject method (not the JScript new ActiveXObject) which has a 2nd optional argument for event sinking.  Also check the WScript.ConnectObject method for object returned to you (as opposed to those you create directly).  In .wsf files, the <object ... events="yes"> element works for sinking events for some but not all COM objects.

--
Michael Harris


  Hello-

  I have some jscript code ( being executed by cscript.exe ) which loads a COM
  Object. This object fires events, and I would like to attach a jscript
  function to these events. I have successfully attached to events in an HTML
  page using the <script for=obj event=env>, but I am not sure how to
  implement this if the code is being interpreted by cscript and is not
  embedded in a web page. Are there any examples anywhere of using
  jscript+events? All of the examples I have found so far appear to be VBS
  centric.

  Thanks -

  John

  --
  John Dunn

  Peak Audio, Inc
  www.peakaudio.com



Fri, 07 Jun 2002 03:00:00 GMT  
 Events+JScript+WSH

No luck trying to handle IE events.  Any ideas? I get this error
WScript.CreateObject: Could not connect object

Set IE = WScript.CreateObject("InternetExplorer.Application")
WScript.ConnectObject IE, "IE_"
IE.Navigate "http://www.msn.com"
WScript.Sleep 2000
Set doc = IE.Document
WScript.Echo doc.title
WScript.DisconnectObject IE

function IE_DocumentComplete()

 WScript.Echo "NavigateComplete2"
 Set doc = IE.document
 WScript.Echo doc.title
 WScript.Echo doc.innerHTML
end function


  See the doc's for the WScript.CreateObject method (not the JScript new ActiveXObject) which has a 2nd optional argument for event sinking.  Also check the WScript.ConnectObject method for object returned to you (as opposed to those you create directly).  In .wsf files, the <object ... events="yes"> element works for sinking events for some but not all COM objects.

  --
  Michael Harris


    Hello-

    I have some jscript code ( being executed by cscript.exe ) which loads a COM
    Object. This object fires events, and I would like to attach a jscript
    function to these events. I have successfully attached to events in an HTML
    page using the <script for=obj event=env>, but I am not sure how to
    implement this if the code is being interpreted by cscript and is not
    embedded in a web page. Are there any examples anywhere of using
    jscript+events? All of the examples I have found so far appear to be VBS
    centric.

    Thanks -

    John

    --
    John Dunn

    Peak Audio, Inc
    www.peakaudio.com



Fri, 14 Jun 2002 03:00:00 GMT  
 Events+JScript+WSH

Set IE = WScript.CreateObject("InternetExplorer.Application","IE_")

ConnectObject doesn't work with an IE Application object.  See the disclaimer in the ConnectObject docs...

--
Michael Harris


  No luck trying to handle IE events.  Any ideas? I get this error
  WScript.CreateObject: Could not connect object

  Set IE = WScript.CreateObject("InternetExplorer.Application")
  WScript.ConnectObject IE, "IE_"
  IE.Navigate "http://www.msn.com"
  WScript.Sleep 2000
  Set doc = IE.Document
  WScript.Echo doc.title
  WScript.DisconnectObject IE

  function IE_DocumentComplete()

   WScript.Echo "NavigateComplete2"
   Set doc = IE.document
   WScript.Echo doc.title
   WScript.Echo doc.innerHTML
  end function


    See the doc's for the WScript.CreateObject method (not the JScript new ActiveXObject) which has a 2nd optional argument for event sinking.  Also check the WScript.ConnectObject method for object returned to you (as opposed to those you create directly).  In .wsf files, the <object ... events="yes"> element works for sinking events for some but not all COM objects.

    --
    Michael Harris


      Hello-

      I have some jscript code ( being executed by cscript.exe ) which loads a COM
      Object. This object fires events, and I would like to attach a jscript
      function to these events. I have successfully attached to events in an HTML
      page using the <script for=obj event=env>, but I am not sure how to
      implement this if the code is being interpreted by cscript and is not
      embedded in a web page. Are there any examples anywhere of using
      jscript+events? All of the examples I have found so far appear to be VBS
      centric.

      Thanks -

      John

      --
      John Dunn

      Peak Audio, Inc
      www.peakaudio.com



Fri, 14 Jun 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem with syntax for sinking events in JScript under WSH

2. Problem with syntax for sinking events in JScript under WSH

3. JScript event handlers in WSH

4. WSH and JScript events

5. haldle OLE events in jscript under wsh?

6. JScript event handler for ActiveX DLL events within IE

7. ActiveX Events in JScript Not Working (VBScript Works Fine)

8. Calling a JScript event handler

9. JScript event and function to test for CR

10. Sinking COM Events in JScript

11. Documentation for event object in MS JScript.

12. Can JScript disable sound events in IExplorer ???

 

 
Powered by phpBB® Forum Software