按键精灵论坛发脚本的格式自动编排脚本源码

帮助你将按键脚本源代码,按照论坛Discuz!语言进行重新格式编排,主要是对语法进行着色,使脚本代码看起来更好看。 

1.演示了如何调用系统打开文件对话框,以及如何根据用户的选择,进行下一步的操作(如打开文件等)。 

2.演示了在“按键精灵”中,VBScript语言与按键精灵语言是怎么紧密结合在一起工作的(在使用中,你如果不注意,根本体会不到是在使用VBS语言)。 

3.演示了如何从头至尾,读取文件中的所有行,以及同时打开两个文件,从一个文件中读、往另外一个文件写操作。 

4.演示如何从文件名获取文件的路径。 

5.演示如何读写INI文件中脚本配置。 

运行环境:分辨率:1440×900 色深:32位 操作系统:Windows XP 按键精灵版本:7.00.3730

@ahfxman, 风烈焰。 2006年9月 

//变量定义   Dim objDialog, fso   Dim fSourceName,fTargetname   Dim sLine, s, stemp1,stemp2   Dim LineLenOld, LineLenNew   Dim MyArray, i1, i, s1   Dim DirPath   //变量初始化   ForReading = 1:ForWriting = 2:ForAppending=8   remColor="Green"   explainColor="Blue"   IniFileName="c:\path.ini"   //============== 主程序 ===============   Gosub 读取路径   Gosub 打开文件   Rem 结束   MessageBox "程序结束, 谢谢使用"   EndScript    //============== 子程序 ===============   Sub 打开文件       Set objDialog = CreateObject("UserAccounts.CommonDialog")       objDialog.Filter = "脚本文件|*.txt"       objDialog.InitialDir = DirPath       intResult = objDialog.ShowOpen       If intResult <> 0           Gosub 保存路径           Gosub 改名           Gosub 格式编辑       Else            Goto 结束       EndIf    Return 打开文件   Sub 保存路径       sTemp2 = objDialog.FileName       MyArray = Split(sTemp2,"\",-1,1)       i = UBound(MyArray)       i1 = 1       s1 = MyArray(0)       While i1<i           s1 = s1 & "\" & MyArray(i1)           i1 = i1+1       EndWhile        s1 = s1 & "\"       Plugin File.WriteINI("setup","路径",s1,IniFileName)   Return 保存路径   Sub 读取路径       DirPath = "c:\"       Plugin DirPath = File.ReadINI("setup","路径",IniFileName)   Return 读取路径   Sub 改名       fSourceName = objDialog.FileName       fTargetName = Replace(fSourceName,".txt",".ini")   Return 改名   Sub 格式编辑       Set fso = CreateObject("Scripting.FileSystemObject")       Set fSource = fso.OpenTextFile(fSourceName, ForReading, True)       Set fTarget = fso.OpenTextFile(fTargetName, ForWriting, True)       While fSource.AtEndOfStream<>true           sLine = fSource.ReadLine()           lineLenOld = Len(sLine)           s=Trim(sLine)           lineLenNew = Len(s)           sTemp1 = Left(s,2)           sTemp2 = Right(s,Len(s)-2)           If s="[General]"               s="[color=" & explainColor & "]" & s           ElseIf s="[Script]"               s="[/color][color=" & explainColor & "]" & s & "[/color]"           ElseIf sTemp1="//"               s="[color=" & remColor & "]" &s &"[/color]"           Else            EndIf            s = Space(lineLenOld-lineLenNew) & s           fTarget.WriteLine(s)       EndWhile        fSource.Close       fTarget.Close       VBSCall RunApp(fTargetName)   Return 格式编辑
相关文件下载地址
©下载资源版权归作者所有;本站所有资源均来源于网络,仅供学习使用,请支持正版!

按键精灵论坛发脚本的格式自动编排脚本源码》有0个想法

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注