JavaScript to play WSH _ basic knowledge

Source: Internet
Author: User
The Windows Script Host (Windows Script Host) provides a language-independent Script Host For the ActiveX Script engine. It allows you to run scripts on Windows desktops or through command lines. It is convenient to do batch processing.
[Play a game] Save the following code as sendkeys. js and double-click it to run it.

The Code is as follows:


Var WshShell = new ActiveXObject ("WScript. Shell ");
WshShell. Run ("Notepad ");
WScript. Sleep (100 );
WshShell. AppActivate ("Notepad ");
WScript. Sleep (100 );
WshShell. SendKeys ("Hello World! {ENTER }");
WScript. Sleep (500 );
WshShell. SendKeys ("^ s ");
WScript. Sleep (500 );
WshShell. SendKeys ("c: \ savedWorld.txt ");
WScript. Sleep (500 );
WshShell. SendKeys ("% s ");


WSH does not involve much content. If you have a good foundation, you can master it within 40 minutes (that is, browsing the tutorial again ).

Here is a Chinese tutorial, is left by the elders of autumn: http://www.blueidea.com/user/qswh/WSH.CHM

This tutorial is old and new information is visible in http://msdn.microsoft.com/library/en-us/script56/html/d78573b7-fc96-410b-8fd0-3e84bd7d470f.asp

The rest is to call the ActiveX components you need, which is also the main pleasure of Windows Scripting. One of the reasons that makes ActiveX technology obsolete is its application in scripts.

In addition to direct script applications, WSH can also be embedded into other programs. The Delphi and VB (6.0) programs use regular expressions in this way.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.