Home > Web Front-end > JS Tutorial > Let's play with WSH with js_basic knowledge

Let's play with WSH with js_basic knowledge

WBOY
Release: 2016-05-16 19:18:49
Original
1543 people have browsed it

Windows Script Host provides a language-independent script host for the ActiveX script engine. It allows running scripts from the Windows desktop or command line. It's very convenient for doing things that require batch processing.
[Have fun] Save the following code as sendkeys.js, and then double-click to run it.

Copy code 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");

The content involved in WSH itself is not Not much. If you have a good foundation, you can basically master it within 40 minutes (that is, you have browsed through the tutorial).

Here is a Chinese tutorial, something left by Senior Qiushui: http://www.blueidea.com/user/qswh/WSH.CHM

This tutorial is relatively old, new information can be found at 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 fun of Windows Scripting. One of the things that future-proofs ActiveX technology is its use in scripts.

In addition to direct script applications, WSH can also be embedded into other programs. Delphi and VB (6.0) programs use regular expressions in this way.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template