足球游戏_中国足彩网¥体育资讯$

winxp下用vbs写的代码编辑器
来源:易贤网 阅读:1120 次 日期:2016-06-30 08:48:02
温馨提示:易贤网小编为您整理了“winxp下用vbs写的代码编辑器”,方便广大网友查阅!

几天不能访问的时候把硬盘上的东东复习了一遍,找出了这个东西出来,由于水平有限,而且对dhtml没有什么研究,所以做得很是粗糙,贴上来是为了抛砖引玉,希望有高人能帮忙修改或拿出更优秀的东东出来。

测试环境为windows xp 专业版 sp2,暂时发现代码着色方面有bug,虽然已有解决方法,不过由于代码量的原因(用记事本写代码真的很恼火),暂时未纠正,另外预计将来加入自动完成等功能。

ps:利用vbs脚本+dhtml,主要功能由正则表达式+wmic来完成,代码需保存为hta类型的文件,当然也可以更改为纯粹的vbs脚本,不过那样效率低多了,而且代码更复杂。

代码如下:

<html>

<head>

<title>代码编辑器</title>

<hta:application selection=no scroll=no contextmenu=no />

<script language=vbscript>

'*******************************************************************'

'脚本开始

'*******************************************************************'

set shell=createobject(wscript.shell)

set fso=createobject(scripting.filesystemobject)

'*******************************************************************'

'遍历本地所有类型文件

'*******************************************************************'

sub optionadd(fext)

str = <select size=1 name=objoption onchange=testsub>

set objdatafiles = getobject(winmgmts: _

& {impersonationlevel=impersonate}!\\.\root\cimv2)

set colfiles = objdatafiles. _

execquery(select * from cim_datafile where extension = ' & fext & ')

for each objfile in colfiles

str = str & <option value= & objfile.name & > & _

objfile.name & </option>

next

str = <label>本地脚本文件:</label> & str & </select>

foroption.innerhtml = str

end sub

'*******************************************************************'

'颜色转换

'*******************************************************************'

sub changecolor

if cxs.value = vbs then

winmain.innerhtml = changevbs(winmain.innertext)

else 'cmd脚本

winmain.innerhtml = changecmd(winmain.innertext)

end if

end sub

'*******************************************************************'

'vbs转换模块

'*******************************************************************'

function changevbs(stext)

set re=new regexp

re.ignorecase =true

re.global=true

'注释转换

re.pattern = (\'.*)\r\n

stext = re.replace(stext,<font color=#339999>$1</font><p>)

'转换符号为[蓝色]

re.pattern = (\(|\)|\&|\+|\-|\*|\%|\:|\;|\.|\ & )

stext = re.replace(stext,<font color=#993333>$1</font>)

stext = <table ><tr><td width='1024' & _

style='word-break:break-all'><ol type=1> & _

<br /><li> & stext & </table>

stext = replace(stext,chr(13) & chr (10) , </li><li> )

'转换保留字为[蓝色]

re.pattern=(\band\b|\bbyref\b|\bbyval\b|\bcall\b & _

|\bcase\b|\bclass\b|\bconst\b|\bdim\b|\bdo\b & _

|\beach\b|\belse\b|\belseif\b|\bempty\b|\bend\b & _

|\beqv\b|\berase\b|\berror\b|\bexit\b|\bexplicit\b & _

|\bfalse\b|\bfor\b|\bfunction\b|\bget\b|\bif\b|\bimp\b & _

|\bin\b|\bis\b|\blet\b|\bloop\b|\bmod\b|\bnext\b|\bnot\b & _

|\bnothing\b|\bnull\b|\bon\b|\boption\b|\bor\b|\bprivate\b & _

|\bproperty\b|\bpublic\b|\brandomize\b|\bredim\b|\brem\b & _

|\bresume\b|\bselect\b|\bset\b|\bstep\b|\bsub\b|\bthen\b & _

|\bto\b|\btrue\b|\buntil\b|\bwend\b|\bwhile\b|\bxor\b|vb[a-z]*)

stext=re.replace(stext,<font color=blue>$1</font>)

'转换函数和对象为[红色]

re.pattern=(\banchor\b|\barray\b|\basc\b|\batn\b & _

|\bcbool\b|\bcbyte\b|\bccur\b|\bcdate\b|\bcdbl\b & _

|\bchr\b|\bcint\b|\bclng\b|\bcos\b|\bcreateobject\b & _

|\bcsng\b|\bcstr\b|\bdate\b|\bdateadd\b|\bdatediff\b & _

|\bdatepart\b|\bdateserial\b|\bdatevalue\b|\bday\b & _

|\bdictionary\b|\bdocument\b|\belement\b|\berr\b|\bexp\b & _

|\bfilesystemobject \b|\bfilter\b|\bfix\b|\bint\b|\bform\b & _

|\bformatcurrency\b|\bformatdatetime\b|\bformatnumber\b & _

|\bformatpercent\b|\bgetobject\b|\bhex\b|\bhistory\b|\bhour\b & _

|\binputbox\b|\binstr\b|\binstrrev\b|\bisarray\b|\bisdate\b & _

|\bisempty\b|\bisnull\b|\bisnumeric\b|\bisobject\b|\bjoin\b & _

|\blbound\b|\blcase\b|\bleft\b|\blen\b|\blink\b|\bloadpicture\b & _

|\blocation\b|\blog\b|\bltrim\b|\brtrim\b|\btrim\b|\bmid\b & _

|\bminute\b|\bmonth\b|\bmonthname\b|\bmsgbox\b|\bnavigator\b & _

|\bnow\b|\boct\b|\breplace\b|\bright\b|\brnd\b|\bround\b & _

|\bscriptengine\b|\bscriptenginebuildversion\b & _

|\bscriptenginemajorversion\b|\bscriptengineminorversion\b & _

|\bsecond\b|\bsgn\b|\bsin\b|\bspace\b|\bsplit\b|\bsqr\b & _

|\bstrcomp\b|\bstring\b|\bstrreverse\b|\btan\b|\btime\b & _

|\btextstream\b|\btimeserial\b|\btimevalue\b|\btypename\b & _

|\bubound\b|\bucase\b|\bvartype\b|\bweekday\b|\bweekdayname\b & _

|\bwindow\b|\byear\b|\bwscript\b)

stext=re.replace(stext,<font color=red>$1</font>)

changevbs = stext

end function

'*******************************************************************'

'cmd转换模块

'*******************************************************************'

function changecmd(stext)

set re=new regexp

re.ignorecase =true

re.global=true

'等号转换

'stext = replace(stext,/,<font color=#ff0000>/</font>)

re.pattern = (\%|\=|\/[a-z]*\b|\>|\<|\|)

stext = re.replace(stext,<font color=#ff8c00>$1</font>)

'注释转换

re.pattern = (rem\b.*\r\n|\brem\b.*)

stext = re.replace(stext,<font color=#20b2aa>$1</font>)

'改变符号的颜色

re.pattern = (\(|\)|\&|\+|\-|\*|\;|\ & )

stext = re.replace(stext,<font size=5 color=#9932cc>$1</font>)

'改变所有命令的颜色

re.pattern = (\bshare\b|\bsetver\b|\bnlsfunc\b|\bmem\b|\blh\b & _

|\bloadhigh\b|\bloadfix\b|\bgraphics\b|\bforcedos\b & _

|\bfastopen\b|\bexe2bin\b|\bedlin\b|\bedlin\b|\bedit\b & _

|\bdebug\b|\bdebug\b|\bappend\b|\bswitches\b|\bstacks\b & _

|\bshell\b|\bntcmdprompt\b|\blastdrive\b|\binstall\b & _

|\bfiles\b|\bfcbs\b|\bechoconfig\b|\bdriveparm\b|\bdosonly\b & _

|\bdos\b|\bdevicehigh\b|\bdevice\b|\bcountry\b|\bbuffers\b & _

|\bxcopy\b|\bwmic\b|\bwinnt32\b|\bwinnt\b|\bw32tm\b & _

|\bvssadmin\b|\bvol\b|\bverify\b|\bver\b|\bunlodctr\b & _

|\btypeperf\b|\btype\b|\btree\b|\btracert\b|\btracerpt\b & _

|\btitle\b|\btime\b|\btftp\b|\btelnet\b|\btcmsetup\b & _

|\btasklist\b|\btaskkill\b|\bsfc\b|\bsysteminfo\b|\bsubst\b & _

|\bstart\b|\bsort\b|\bshutdown\b|\bshift\b|\bsetlocal\b|\bset\b & _

|\bsecedit\b|\bschtasks\b|\bsc\b|\brunas\b|\brsm\b|\brsh\b & _

|\broute\b|\brmdir\b|\brexec\b|\breset\b|\breplace\b|\brename\b & _

|\brelog\b|\bregsvr32\b|\breg\b|\brecover\b|\brcp\b|\brasdial\b & _

|\bquery\b|\bpushd\b|\bprompt\b|\bprnqctl\b|\bprnport\b & _

|\bprnmngr\b|\bprnjobs\b|\bprndrvr\b|\bprncnfg\b|\bprint\b & _

|\bpopd\b|\bping\b|\bperfmon\b|\bpentnt\b|\bpbadmin\b|\bpause\b & _

|\bpathping\b|\bpath\b|\bpagefileconfig\b|\bopenfiles\b|\bntsd\b & _

|\bntcmdprompt\b|\bntbackup\b|\bnslookup\b|\bnetstat\b|\bnetsh\b & _

|\bnet\b|\bnbtstat\b|\bmsinfo32\b|\bmsiexec\b|\bmove\b & _

|\bmountvol\b|\bmore\b|\bmode\b|\bmmc\b|\bmd\b|\bmkdir\b & _

|\bmacfile\b|\blpr\b|\blpq\b|\blogman\b|\blodctr\b|\blabel\b & _

|\birftp\b|\bipxroute\b|\bipseccmd\b|\bipconfig\b|\bif\b & _

|\bhostname\b|\bhelpctr\b|\bhelp\b|\bgraftabl\b|\bgpupdate\b & _

|\bgpresult\b|\bgoto\b|\bgetmac\b|\bftype\b|\bftp\b|\bfsutil\b & _

|\bformat\b|\bfor\b|\bflattemp\b|\bfinger\b|\bfindstr\b|\bfind\b & _

|\bfc\b|\bexpand\b|\bexit\b|\bevntcmd\b|\beventtriggers\b & _

|\beventquery\b|\beventcreate\b|\bendlocal\b|\becho\b & _

|\bdriverquery\b|\bdoskey\b|\bdiskpart\b|\bdiskcopy\b & _

|\bdiskcomp\b|\bdir\b|\bdel\b|\bdefrag\b|\bdate\b|\bcscript\b & _

|\bcprofile\b|\bcopy\b|\bconvert\b|\bcompact\b|\bcomp\b & _

|\bcmstp\b|\bcmd\b|\bcls\b|\bcipher\b|\bchkntfs\b|\bchkdsk\b & _

|\bchdir\b|\bchcp\b|\bchange\b|\bcall\b|\bcacls\b|\bbreak\b & _

|\bbootcfg\b|\battrib\b|\batmadm\b|\bat\b|\bassoc\b|\barp\b)

stext=re.replace(stext,<font color=blue>$1</font>)

stext = <table><td width=1024 & _

style=word-break:break-all><ol type=1> & _

<br /><li> & stext & <tr></table>

stext = replace(stext,chr(13) & chr (10) , </li><li> )

changecmd = stext

end function

'*******************************************************************'

'帮助窗口

'*******************************************************************'

set opopup = window.createpopup

sub helpwindow

if usehelp.checked then

set opopbody = opopup.document.body

opopbody.style.backgroundcolor = lightyellow

opopbody.style.border = solid black 1px

opopbody.innerhtml = 帮助功能未完成,取消帮助见右下角

opopup.show winmain.offsetleft, _

winmain.offsettop + winmain.offsetheight - 20, _

winmain.offsetwidth, 20, document.body

end if

end sub

'*******************************************************************'

'运行代码

'*******************************************************************'

sub runcode

if cxs.value = vbs then

tmpfile = temp_script.vbs

str = tmpfile

else

tmpfile = temp_script.bat

str = cmd /k & tmpfile

end if

set file = fso.opentextfile(tmpdir & tmpfile,2,true)

file.write winmain.innertext

file.close

shell.run str

end sub

'*******************************************************************'

'保存文件

'*******************************************************************'

sub savefile

set objdialog = createobject(safrcfiledlg.filesave)

objdialog.filename = cstr(date)

if cxs.value = vbs then

objdialog.filetype = .vbs

else

objdialog.filetype = .bat

end if

intreturn = objdialog.openfilesavedlg

if intreturn then

set objfile = fso.createtextfile( _

objdialog.filename & objdialog.filetype)

objfile.writeline winmain.innertext

objfile.close

end if

end sub

'*******************************************************************'

'打开文件

'*******************************************************************'

sub openfile

set objdialog = createobject(useraccounts.commondialog)

objdialog.filter = bat文件|*.bat;*.cmd|vbs 文件|*.vbs|所有文件|*.*

'objdialog.maxfilesize = 10000

'objdialog.filterindex = 1

'objdialog.initialdir =

objdialog.showopen

'strloadfile = objdialog.filename

if len(trim(objdialog.filename)) = 0 then exit sub

set objfile = fso.opentextfile(objdialog.filename,1,true)

winmain.innertext = objfile.readall

end sub

'*******************************************************************'

'启动时自动移动到屏幕中心

'*******************************************************************'

sub window_onload()

self.resizeto 1,1

self.moveto 300,300

'显示一个窗口

set objwindow = window.open(about:blank,progresswindow,height=15,width=250,left=300,top=300,status=no,titlebar=no,toolbar=no,menubar=no,location=no,scrollbars=no)

with objwindow

.focus()

.resizeto 250,15

.document.body.style.fontfamily = helvetica

.document.body.style.fontsize = 11pt

.document.writeln <html><body>正在搜索本地文件....</body></html>

.document.title = 请稍侯...

.document.body.style.backgroundcolor = buttonface

.document.body.style.borderstyle = none

.document.body.style.margintop = 15

end with

'如果系统并非xp,ie不为6.0版本则退出

strwindowsver = shell.regread _

(hklm\software\microsoft\windows nt\currentversion\productname)

striever = shell.regread _

(hklm\software\microsoft\internet explorer\version)

if strwindowsver <> microsoft windows xp or _

left(striever,3) <> 6.0 then

intflag = msgbox(操作系统不是xp或者ie版本低于6.0,是否退出?,1)

if intflag = 1 then

self.close

else

began

end if

else

began

end if

objwindow.close

end sub

sub began

optionadd bat

intleft = (document.parentwindow.screen.availwidth - 800) / 2

inttop = (document.parentwindow.screen.availheight - 600) / 2

window.resizeto 800,650

window.moveto intleft, inttop

end sub

'*******************************************************************'

'搜索本地脚本

'*******************************************************************'

sub testsub

set objfile = fso.opentextfile(objoption.value,1,true)

winmain.innertext = objfile.readall

end sub

'*******************************************************************'

'擦屁股

'*******************************************************************'

sub window_onbeforeunload()

on error resume next

fso.deletefile temp_script.vbs,true

fso.deletefile temp_script.bat,true

set shell = nothing

set fso = nothing

set opopup= nothing

end sub

'*******************************************************************'

'清空代码

'*******************************************************************'

sub clear

winmain.innertext =

'winmain.innerhtml =

end sub

'*******************************************************************'

'复制到剪贴板

'*******************************************************************'

sub clipboard

window.clipboarddata.setdata text, winmain.innerhtml

end sub

</script>

</head>

<body>

<style type=text/css>

* { padding:0; border:0; overflow:hidden; font:16px arial;}

html,body { height:100%; margin:0;}

#box_2 { height:100%; background:#ccc;}

</style>

<center>

<div style=font-family: trebuchet ms; font-weight:bold;>

<span style=font-size: 18pt;>代码编辑器</span>

<span style=font-size: 8pt;>ver 1.0 by

<a href=http://www.cn-dos.net/forum/forumdisplay.php?fid=23>

3742668</a>   <a href=mailto:3742668@gmail.com>

我的信箱</a></span><br></div></center><br> <div contenteditable

style=padding:2; overflow:auto;background-color:lightyellow;

width:100%; height:70%; id=winmain onkeyup=helpwindow>

</div> <br> <center>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=打开文件(x)

accesskey=x onclick=openfile>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=运行代码(r)

accesskey=r onclick=runcode>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=清空代码(c)

accesskey=c onclick=clear>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=保存文件(s)

accesskey=s onclick=savefile>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=复制着色代码(a)

accesskey=a onclick=clipboard>

<input style=font-family: trebuchet ms; font-size: 8pt; font-weight:

bold; border: 1px solid black; type=button value=着色显示(d)

accesskey=d onclick=changecolor></center>

<br><div id=foroption></div><p>

<input type=checkbox id=usehelp onfocus=winmain.focus

accesskey=z class=noborder position: checked>

<label for=usehelp>使用帮助(<u>z</u>)</label>  

   <label>脚本类型:<label>

<select name=cxs size=1 onchange=optionadd(cxs.value)>

<option value=vbs>

vbs脚本</option><option value=bat selected>bat脚本</option><br>

</body>

</html> 

中国足彩网信息请查看脚本栏目
易贤网手机网站地址:winxp下用vbs写的代码编辑器
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标