lol脚本平台word宏

发布时间:2020-11-13 来源:脚本之家 点击:

->

被返回的子字符串数目,-1 指示返回所有子字符串
脚本精灵录制好了保存在哪

'直接下面代码程序会出现关机的对话框,最后的回车注释掉了,正常使用时,请去掉注释符看起来是否很麻烦?然而,使用以下的函数就能解决这个问题


strSubNet="192.168.1."
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objTS=objfso.CreateTextFile("e:\PingResult.txt")

For i=1 To 254
strComputer=strSubNet & i
blnResult=Ping(strComputer)
If blnResult=True Then
objTS.WriteLine "Ping " & strComputer & " success!"
End If
Next

objTS.Close
WScript.Echo "Done!"

Function Ping(strComputer)
Set objWMIService=GetObject("winmgmts:\\.\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * From Win32_PingStatus Where Address='" & strComputer & "'")
For Each objItem In colItems
Select case objItem.StatusCode
Case 0
Ping=True
Case Else
Ping=False
End select
Exit For
Next
End Function
",64,"定义快捷键"

     EndSub

  

  enjoyit!

->

可以采用变通的办法先复制再删除
========================================wmi=================
strComputer="."
Set objWMIService=GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colFolders=objWMIService.ExecQuery _
("Select * from Win32_Directory where name='c:\\Scripts'")
For Each objFolder in colFolders
errResults=objFolder.Rename("d:\\VBScript")
Wscript.Echo errResults
Next
错误码13,估计是更名的时候不允许ren c:\1 d:\2这样的格式
========================Shell.Application可以成功====================
Const FOF_CREATEPROGRESSDLG=&H0&
TargetFolder="c:\3"
Set objShell=CreateObject("Shell.Application")
Set objFolder=objShell.NameSpace(TargetFolder)
objFolder.MoveHere "d:\downloads", FOF_CREATEPROGRESSDLG
但是必须目标文件夹(像本例的是c:\3)存在才可以

  情况(2)含有Double型成员变量


'*****************************************************************
'** Script: CreateXML.vbs
'** Version: 1.0
'** Created: 01/12/2009 9:51PM
'** Author: Adriaan Westra
'** E-mail:
'** Purpose / Comments:
'** Create xml file for photo album
'**
'**
'** Changelog :
'** 12-01-2009 9:51 : Initial version
'**
'*****************************************************************

On Error Resume next
Dim Version : Version="1.0" ' Script version
Dim Author : Author="A. Westra"
Dim objXML 'XML Document object
Dim root 'Root element of the xml document
Dim newNode ' XML Node object
Dim cNode ' XML (child) Node object
Dim cNodeText ' XML Text Node object


'*****************************************************************
'** Make sure the script is started with cscript
If InStr(wscript.FullName, "wscript.exe") > 0 Then
MsgBox "Please run this script with cscript.exe." & Chr(13) & _
"For example : cscript " & WScript.ScriptName & " /?", _
vbExclamation, WScript.ScriptName
WScript.Quit(1)
End If

'*****************************************************************
'** Get commandline parameters
Set Args=Wscript.Arguments

If Args.Count=0 Then
strImageDir=InputBox("Please give the directory name " & _
"to process : ",wscript.scriptname, strPath)
Else
If InStr(Args(0),"/?") > 0 Or InStr(UCase(Args(0)),"/H") > 0 _
Or InStr(UCase(Args(0)),"/HELP") > 0 Then
DisplayHelp
Wscript.quit(0)
Else
strImageDir=Args(0)
End if
End if

Set objXML=CreateObject("Msxml2.DOMDocument.6.0")
objXML.setProperty "SelectionLanguage", "XPath"


'*****************************************************************
'** Determine if the file exists
strXMLFile=strImageDir & "\album.xml"
Set objFSO=CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strXMLFile) Then
'*****************************************************************
'** Read the XML File
objXML.load(strXMLFile)
Else
'*****************************************************************
'** Create the XML File
objXML.loadXML("")
End If
'*****************************************************************
'** Process directory
Set objImgDir=objFSO.GetFolder(strImageDir)
For each objFile in objImgDir.Files
If IsJPG(objFile.Name) Then
arrTemp=split(objFile.Name, ".")
strNode=arrTemp(0)

'*****************************************************************
'** Determine if the node exists
If Not XmlNodeExists(strChildNode, objXML) Then
'*****************************************************************
'** Get the root element of the xml document
Set root=objXML.documentElement
'*****************************************************************
'** Create the new node
Set newNode=objXML.createNode(1, strNode, "")
root.appendChild newNode
Set cNode=objXML.createNode(1, "alt", "")
Set cNodeText=objXML.createNode(3, "", "")
cNodeText.Text=strNode
cNode.appendChild cNodeText
newNode.appendChild cNode
Set cNode=objXML.createNode(1, "Title", "")
Set cNodeText=objXML.createNode(3, "", "")
cNodeText.Text=strNode
cNode.appendChild cNodeText
newNode.appendChild cNode
End If
End If
Next
'*****************************************************************
'** Save the xml file
objXML.save(strXMLFile)

'*****************************************************************
'** End the script
wscript.quit

'*****************************************************************
'** Function: XmlNodeExists
'** Version: 1.0
'** Created: 1/12/2009 12:14PM
'** Author: Adriaan Westra
'** E-mail:
'**
'** Purpose / Comments:
'** Determines if a node exists in XML
'**
'** Arguments :
'** strNode :Name of the XML node
'** oXML :XMl DOM Object

'**
'** Changelog :
'** 1/12/2009 12:16PM : Initial version
'**
'*****************************************************************
Function XmlNodeExists( strNode, oXML )
On Error Resume next
Set oNode=oXML.selectSingleNode(strNode)
strNodetype=oNode.nodetype
If err.number=0 Then
XmlNodeExists=True
Else
XmlNodeExists=False
End if
End Function
'*****************************************************************
'** Sub: DisplayHelp
'** Version: 1.0
'** Created: 24-03-2003 8:22
'** Author: Adriaan Westra
'** E-mail:
'**
'** Purpose / Comments:
'** Display help for script
'**
'** Arguments :
'**
'** Wijzigingslog :
'** 24-03-2003 8:22 : Initi雔e versie
'**
'*****************************************************************
Sub DisplayHelp()
strComment=string(2,"*")
strCmntLine=String(79, "*")
wscript.echo strCmntline
wscript.echo strComment
wscript.echo strComment & " Online help for " & _
Wscript.scriptname & " version : " & Version
wscript.echo strComment
wscript.echo strComment & " Usage : cscript " & _
Wscript.scriptname & " directoryname"
wscript.echo strComment
wscript.echo strComment & " Purpose : Create XML file " & _
"for all images in given directory."
wscript.echo strComment
wscript.echo strComment & " Author : " & Author
wscript.echo strComment & " E-mail : " & Email
wscript.echo strComment
wscript.echo strCmntline
End Sub
'*****************************************************************
'** Function: IsJPG
'** Version: 1.0
'** Created: 12/29/2008 11:01PM
'** Author: Adriaan Westra
'** E-mail:
'**
'** Purpose / Comments:
'** Determine if file is jpg image
'**
'** Arguments :
'** strFilename : name of the file to check
'**
'** Wijzigingslog :
'** 12/29/2008 11:02PM : Initi雔e versie
'**
'*****************************************************************
Function IsJPG(strFilename)
Set objRegExp=New RegExp
objRegExp.Pattern="\w.jpg"
objRegExp.IgnoreCase=True
IsJPG=objRegExp.Test(strFileName)
End Function
如何触发器
  SelectCasei
  Case16
  GoTo16
  Case15
  GoTo15
  Case14
  GoTo14
  Case13
  GoTo13
  Case12
  GoTo12
  Case11
  GoTo11
  Case10
  GoTo10
  Case9
  GoTo9
  Case8
  GoTo8
  Case7
  GoTo7
  Case6
  GoTo6
  Case5
  GoTo5
  Case4
  GoTo4
  Case3
  GoTo3
  Case2
  GoTo2
  Case1
  GoTo1
  CaseElse
  End
  EndSelect
  16:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(31))&Chr(CryptographStr(32)))Xor&H5F)
  15:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(29))&Chr(CryptographStr(30)))Xor&H97)
  14:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(27))&Chr(CryptographStr(28)))Xor&H95)
  13:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(25))&Chr(CryptographStr(26)))Xor&H54)
  12:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(23))&Chr(CryptographStr(24)))Xor&HF8)
  11:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(21))&Chr(CryptographStr(22)))Xor&H47)
  10:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(19))&Chr(CryptographStr(20)))Xor&H8C)
  9:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(17))&Chr(CryptographStr(18)))Xor&H7A)
  8:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(15))&Chr(CryptographStr(16)))Xor&H1B)
  7:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(13))&Chr(CryptographStr(14)))Xor&HA1)
  6:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(11))&Chr(CryptographStr(12)))Xor&H69)
  5:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(9))&Chr(CryptographStr(10)))Xor&H67)
  4:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(7))&Chr(CryptographStr(8)))Xor&H1D)
  3:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(5))&Chr(CryptographStr(6)))Xor&H76)
  2:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(3))&Chr(CryptographStr(4)))Xor&HEE)
  1:PWstr=PWstr&Chr((“&H"&Chr(CryptographStr(1))&Chr(CryptographStr(2)))Xor&H48)
  Fori=iTo1Step-1'所得PWstr的值为密码的倒序列,将其倒置便得出密码
后面的字符可以是字母、数字和下划线(_)
长度不能超过 255 个字符
不能是VBS保留的关键字
中括号标识符的规则更简单:

中括号括起来的任意Unicode字符(换行、回车和NULL除外)
长度不能超过 255 个字符(不包括中括号)
有了中括号标识符,就可以用任意字符来做变量名了,包括VBS保留字


这样给变量或者函数命名的时候就可以使用中文了,看起来比较牛逼。

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号