|
1.c# 脚本,如何使用数组
function test()
{
var string = "a,b,c,d";
var strings_arr = string["split"](",");
for (var i = 0; i < strings_arr["length"]; i++)
{
Log["Message"](strings_arr)
}
}
2.例子 html脚本
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<select name="TypeSpeed:listTypes" id="TypeSpeed_listTypes" multiple="multiple" size="7" class="listboxRequired" tabindex="2">
<option value="110-APCO">110-APCO</option>
<option value="120-APCO">120-APCO</option>
<option value="130-APCO">130-APCO</option>
<option value="150-APCOCHM">150-APCOCHM</option>
<option value="320-ES">320-ES</option>
<option value="326A">326A</option>
<option value="330">330</option>
<option value="3340">3340</option>
<option value="3350">3350</option>
<option value="340/360-ENCL">340/360-ENCL</option>
<option value="360-SEMIOP">360-SEMIOP</option>
<option value="370-ES">370-ES</option>
<option value="380-INLINE">380-INLINE</option>
<option value="390-STACKABL">390-STACKABL</option>
<option value="410-HSC">410-HSC</option>
<option value="420-HSC">420-HSC</option>
<option value="430-HSC">430-HSC</option>
<option value="520-SUMP">520-SUMP</option>
<option value="530-ENCLOSED">530-ENCLOSED</option>
<option value="530-SEMIOP">530-SEMIOP</option>
<option value="610-NONCLOG">610-NONCLOG</option>
<option value="630-SEWAGE">630-SEWAGE</option>
<option value="640-SEWAGE">640-SEWAGE</option>
<option value="650-NONCLOG">650-NONCLOG</option>
<option value="660-NCV">660-NCV</option>
<option value="670-VORTEX">670-VORTEX</option>
</select>
</body>
</html>
测试脚本: VBScript
sub test1
dim page
dim w, p
set p = Sys.Process("IEXPLORE")
set w = p.Window("IEFrame", "*")
Set page = w.Page("*").ToURL("file:///C:/temp/test.htm")
page.refresh
Call page.SELECT.TypeSpeed_listTypes.Click("120-APCO")
Call page.SELECT.TypeSpeed_listTypes.Click("130-APCO", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("320-ES", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("3340", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("340/360-ENCL", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("670-VORTEX", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("410-HSC", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("530-ENCLOSED", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("640-SEWAGE", skCtrl)
Call page.SELECT.TypeSpeed_listTypes.Click("110-APCO", skCtrl)
end sub
3.读取文件:
function ReadFile(NameNPath)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(NameNPath,1);
return f.ReadAll();
}
4.调试器不起作用
一. 注册Microsoft Script engine. 下载:
http://msdn.microsoft.com/isapi/ ... &DisplayLang=en
二.终止MDM.exe进程.
三. 检查注册表:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{78A51822-51F4-11D0-8F20-00805F2CD064}\InprocServer32
包含pdm.dll 路径和是否这个库存在.
四. 注册这个dll:
regsvr32 C:\WINDOWS\System32\pdm.dll
5.获得文件名称
[C#Script]
function fsoTest(){ var fso = Sys.GetOleObject("Scripting.FileSystemObject"); var folder = fso.GetFolder("c:\\"); var folders = new Enumerator(folder.SubFolders); for (; !folders.atEnd(); folders.moveNext()) Log.Message(folders.item());}
6.查找安装进程文件
Public Function GetMSIProcfor i = 1 to 5set msiproc = Sys.WaitProcess("msiexec", 2000, False,i)if msiproc.Exists thenif msiproc.ChildCount > 0 thenset GetMSIProc = msiprocexit functionend ifend ifnextMsgbox "Could not find msiproc with Children terminating"end Function
7.代码例子
Public Function fGetPrivateProfileString(sSection, sKey, sFilePath)
Dim oWSHINI
Dim sDefault
Dim sReturnedString
Dim lSize
Set oWSHINI = CreateObject("WSHINI.ini")
sDefault = "Unknown"
sReturnedString = Space(255)
lSize = Len(sReturnedString)
fGetPrivateProfileString = oWSHINI.XGetPrivateProfileString(CStr(sSection), CStr(sKey), CStr(sDefault), CStr(sReturnedString), CLng(lSize), CStr(sFilePath))
Set oWSHINI = Nothing
End Function
Public Sub fWritePrivateProfileString(sSection, sKey, sValue, sFilePath)
Dim oWSHINI
Set oWSHINI = CreateObject("WSHINI.ini")
Call oWSHINI.XWritePrivateProfileString(CStr(sSection), CStr(sKey), CStr(sValue), CStr(sFilePath))
Set oWSHINI = Nothing
End Sub |
|