Created
December 25, 2012 17:38
-
-
Save subzey/4374329 to your computer and use it in GitHub Desktop.
Events handling in WSH + JScript example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new InternetExplorer.Application object | |
// 2nd arg is a prefix for events (any string) | |
var ie = WScript.CreateObject("InternetExplorer.Application", "ieEvent_"); | |
// Set url | |
ie.Navigate("about:blank"); | |
// Show window (default state is hidden) | |
ie.Visible = 1; | |
// Create specially named function using prefix (that 2nd arg above) | |
// (OnQuit means when IE window is closed) | |
// This callback must be in global scope! | |
function ieEvent_OnQuit(){ | |
// Do something useful | |
WScript.echo('quit'); | |
// Terminate script | |
WScript.quit(); | |
} | |
// Infinite idle loop waiting for callback | |
// (There's no main loop in WSH/JS so there's no sweet setTimeout/setInterval) | |
while (true){ | |
WScript.sleep(1000); | |
} | |
// End of this hell script |
aerze
commented
Feb 19, 2014
Thank u!
Found where it's documented (WSH CreateObject Method Remarks)
( http://msdn.microsoft.com/en-us/library/xzysf6hc(v=vs.84).aspx )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment