标题: [原创] 做了个vbs编辑器 [打印本页]
作者: jyswjjgdwtdtj 时间: 2023-5-3 13:49 标题: 做了个vbs编辑器
本帖最后由 jyswjjgdwtdtj 于 2023-5-21 21:28 编辑
在后面 在后面
作者: yyz219 时间: 2023-5-3 14:29
谢谢分享哦
作者: jyswjjgdwtdtj 时间: 2023-5-3 14:29
回复 1# jyswjjgdwtdtj
哦 对了 要整个jquery1.7
其实改改可以不用jq的
作者: LTSC1809 时间: 2023-5-3 14:33
为什么报错
作者: jyswjjgdwtdtj 时间: 2023-5-3 14:40
回复 4# LTSC1809
因为你没下载jquery
你要去下载个1.x版本的jq
作者: LTSC1809 时间: 2023-5-3 14:46
回复 5# jyswjjgdwtdtj
哦,我下载的是3.3.1的
作者: LTSC1809 时间: 2023-5-3 14:47
回复 6# LTSC1809 还有,为什么我打开方式是计算机程序,用ie运行它只会问我要下载还是运行
作者: jyswjjgdwtdtj 时间: 2023-5-3 15:41
回复 7# LTSC1809
因为它不是网页啊 他要运行在mshta.exe
作者: jyswjjgdwtdtj 时间: 2023-5-3 15:41
回复 6# LTSC1809
新版本不支持ie7
作者: jyswjjgdwtdtj 时间: 2023-5-3 15:41
本帖最后由 jyswjjgdwtdtj 于 2023-5-3 16:17 编辑
我在改成不要jquery的
然后就不能用了………………
作者: LTSC1809 时间: 2023-5-4 19:05
我电脑上没有IE7,只有IE11,可以运行吗?毕竟现在windows10
作者: jyswjjgdwtdtj 时间: 2023-5-4 19:32
回复 11# LTSC1809
但你电脑上总归有mshta.exe吧?这hta本来就不是在ie上运行的!
作者: LTSC1809 时间: 2023-5-4 22:41
回复 12# jyswjjgdwtdtj 我也觉得奇怪,既然又没用ie来运行,那高版本的jq支持库不支持ie7有什么关系,又用不到ie,管它支不支持呢
作者: jyswjjgdwtdtj 时间: 2023-5-5 20:11
回复 13# LTSC1809
哇兄弟你要把我搞抓狂了!mshta.exe就是没有navigator等等对象的ie7!
作者: LTSC1809 时间: 2023-5-5 21:43
回复 14# jyswjjgdwtdtj
抱歉,对这方面的了解甚少,之前一直以为windows上只有Windows Script Host和浏览器两种脚本解释器...
作者: jyswjjgdwtdtj 时间: 2023-5-5 22:45
回复 15# LTSC1809
你直接双击就可以了
作者: jyswjjgdwtdtj 时间: 2023-5-15 22:33
本帖最后由 jyswjjgdwtdtj 于 2023-5-16 22:14 编辑
保存为hta!- <!--without jquery-->
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" type="text/css" href="editor.css" >
- </head>
- <body>
- <div class="editor_font" id="editor_main">
- <div class="editor_font" id="editor_code">
- <center class="editor_font editor_block" id="editor_list"style=""></center>
- <div class="editor_font" id="editor_place">
- <div class="editor_font editor_block" id="editor_text"></div>
- <div class="editor_font" id="editor_activeline">
- <span class="editor_font editor_block" id="editor_inputcursor"></span>
- <div class="editor_font" id="editor_active"><div>
- </div>
- </div>
- </div>
- </div>
- <div id=debug></div>
- <script language=javascript src="fn.js"></script>
- <script language=vbscript src="format.vbs"></script>
- <script language="javascript">
- //new ActiveXObject("vbscript.regexp")
- //def functions
- //def variates
- var main = byid("editor_main"),
- code = byid("editor_code"),
- list = byid("editor_list"),
- place = byid("editor_place"),
- text = byid("editor_text"),
- activeline = byid("editor_activeline"),
- active = byid("editor_active"),
- cursor = byid("editor_inputcursor"),
- fninfo = byid("fninfo"),
- debug = byid("debug"),
- body = document.body;
- var left_c = 0,
- top_l = 0,
- len_c = 0,
- tlen_l = 0;
- var usingline;
- //def element events
- window.onload = function() {
- var newline = ele("div");
- newline.className = "editor_font editor_line";
- text.appendChild(newline);
- usingline = newline;
- resetli();
- main.focus();
- }
- function addendcode(endcode){
- enter();
- write(endcode);
- for(var i=0,l=active.innerText.length;i<=l;i++){
- cursorbackward()
- }
- enter();
- write(" ");
- }
- main.onkeydown = function() {
- var keycode = event.keyCode,
- ctrl = event.ctrlKey,
- shift = event.shiftKey,
- alt = event.altKey;
- switch (keycode) {
- case 37: //left
- cursorbackward();
- break;
- case 39: //right
- cursorforward();
- break;
- case 38: //up
- if (top_l) {
- usingline.innerHTML = format.word(format.Space(active.innerText));
- top_l--;
- usingline = usingline.previousSibling;
- active.innerHTML = usingline.innerHTML;
- resettop();
- len_c = usingline.innerText.length;
- left_c = left_c > len_c ? len_c : left_c;
- resetleft();
- usingline.innerText = "";
- }
- break;
- case 40: //down
- if (tlen_l - top_l) {
- usingline.innerHTML = format.word(format.Space(active.innerText));
- top_l++;
- usingline = usingline.nextSibling;
- active.innerHTML = usingline.innerHTML;
- resettop();
- len_c = usingline.innerText.length;
- left_c = left_c > len_c ? len_c : left_c;
- resetleft();
- usingline.innerText = "";
- }
- break;
- case 13: //enter
- t=active.innerText;
- var re=new ActiveXObject("vbscript.regexp")
- re.ignorecase=true
- re.pattern="^[ ]*If[ ]+.*?[ ]+Then[ ]*$"
- if(re.test(t)){
- addendcode("end if")
- return;
- }
- re.pattern="^[ ]*(for[ ]+.*?[ ]*=[ ]*.*?[ ]+to[ ]+.*?|for[ ]+each[ ]+.*?[ ]+in[ ]+.*?)$"
- if(re.test(t)){
- addendcode("next")
- return;
- }
- re.pattern="^[ ]*select[ ]+case[ ]+.*?$"
- if(re.test(t)){
- addendcode("end select")
- return;
- }
- re.pattern="^[ ]*(do|do[ ]+(until|while)[ ]+.*?)[ ]*$"
- if(re.test(t)){
- addendcode("loop")
- return;
- }
- re.pattern="^[ ]*while[ ]+.*?[ ]*$"
- if(re.test(t)){
- addendcode("wend")
- return;
- }
- re.pattern="^[ ]*with[ ]+.*?[ ]*$"
- if(re.test(t)){
- addendcode("end with")
- return;
- }
- re.pattern="^[ ]*((private|public)[ ]+)?function[ ]+\(.*?\)[ ]*$"
- if(re.test(t)){
- addendcode("end function")
- return;
- }
- re.pattern="^[ ]*((private|public)[ ]+)?sub[ ]+\(.*?\)[ ]*$"
- if(re.test(t)){
- addendcode("end sub")
- return;
- }
- re.pattern="^[ ]*class[ ]+\(.*?\)[ ]*$"
- if(re.test(t)){
- addendcode("end class")
- return;
- }/**/
- enter();
- break;
- case 8: //backspace
- back(1)
- break;
- case 46: //delete
- if (left_c < len_c) {
- cursorforward();
- back(1);
- } else if (left_c == len_c) {
- if (top_l == tlen_l) {
- break;
- }
- var next = usingline.nextSibling;
- tlen_l--;
- active.innerHTML = format.word(format.space(active.innerText + next.innerText));
- text.removeChild(next);
- len_c = active.innerText.length;
- resetli();
- resetleft();
- }
- break;
- case 32: //space
- write(" ");
- break;
- case 9: //tab
- if(shift){write(" ");return false;}
- write(" ");
- return false;
- break;
- case 67://KEY-C
- if(ctrl){
- usingline.innerText=active.innerText
- window.clipboardData.setData("Text", text.innerText)
- }
- break;
- case 112://F1
- alert(active.innerHTML);
- break;
- case 113://F2
- alert(byid("editor_text").innerHTML)
- break;
- case 114://F3
- alert(body.innerHTML)
- break;
- }
- }
- main.onkeypress = function() {
- var keycode = event.keyCode;
- if (33 >= keycode || keycode == 127) {
- return;
- }
- t=active.innerText
- var ctrl = event.ctrlKey;
- var shift = event.shiftKey;
- var alt = event.altKey;
- if(keycode==58){
- var re=new ActiveXObject("vbscript.regexp")
- re.pattern="[ ]*If[ ]+.*?[ ]+Then[ ]+.+$"
- if(!re.test(t)){
- enter();
- return;
- }
- }
- write(chr(keycode));
- }
- var select=false,
- mouseon=false,
- downleft=0,
- upleft=0
- downtop=0
- uptop=0;
- main.onmousedown=function(){
- var l = Math.round((window.event.clientX - 10 - 50) / 12);
- var t = Math.round((window.event.clientY - 30 + code.scrollTop) / 26); //为啥是30我也不知道
- l=l<0?0:l;
- t=t<0?0:t;
- setTimeout(function(){
- if(!mouseon){return;}
- usingline.innerHTML = format.word(format.space(active.innerText));
- lines=text.children;
- top_l = t > tlen_l ? tlen_l : t;
- len_c = lines[top_l].innerText.length;
- left_c = len_c > l ? l : len_c;
- usingline = lines[top_l];
- active.innerHTML=format.word(format.space(usingline.innerText));
- usingline.innerText = "";
- resettop();
- resetleft();
- },0)
- mouseon=true;
- }
- main.onmouseup=function(){
- mouseon=false
- }
- document.onselectstart=function(){return false}
- </script>
- </body>
- </html>
复制代码
作者: jyswjjgdwtdtj 时间: 2023-5-15 22:38
保存为fn.js复制代码
保存为editor.css- .editor_font {
- font-family:Consolas;
- font-size:22px;
- }
- .editor_block {
- position:absolute;
- }
- .space {
- display:inline;
- }
- #debug {
- position:absolute;
- bottom:50px;
- height:50px;
- width:100%;
- background:#999999;
- ddisplay:none;
- }
- .string {
- color:#A52A2A
- }
- .comment {
- color:#FFA500
- }
- .functions {
- color:#800080
- }
- .reservedwords {
- color:#008000
- }
- .variants {
- color:#0000FF
- }
- .operators{
- color:#FFA500
- }
- .specialwords {
- color:yellow;
- }
- .uselesswords {
- color:red;
- }
- .number {
- color:#B5CEA8
- }
- body {
- overflow:hidden;
- background:#F5F5F5
- color:black;
- }
- #editor_main {
- height:100%;
- width:100%;
- }
- #editor_code {
- height:100%;
- overflow-y:scroll;
- }
- #editor_list {
- left:0px;
- width:50px;
- height:100%;
- background:#D3D3D3
- color:#FFFFFF
- }
- #editor_place {
- position:relative;
- height:100%;
- width:100%;
- left:50px;
- }
- #editor_text {
- height:100%;
- width:100%;
- }
- .editor_line {
- color:black;
- }
- #editor_activeline {
- position:relative;
- }
- #editor_inputcursor {
- width:1px;
- background:black;
- }
- #editor_active {
- color:#ADD8E6
- height:25px;
- width:100%;
- }
复制代码
作者: jyswjjgdwtdtj 时间: 2023-5-15 22:38
本帖最后由 jyswjjgdwtdtj 于 2023-5-16 18:40 编辑
保存为format.vbs- uselesswords="As Boolean Byte Currency Double Empty EndIf Enum Implements Integer Like Long LSet Optional "&_
- "ParamArray RaiseEvent RSet Shared Single Static Type TypeOf Variant"
- specialwords="Debug Stop"
- reservedwords="ByRef ByVal Call Case Class Const Dim Do Each Else ElseIf End Event Exit Explicit "&_
- "False For Function Get Goto If In Let Loop Me "&_
- "New Next Nothing Null On Option Preserve Private Property Public "&_
- "ReDim Rem Resume Select Set Sub Step Then To True "&_
- "Until WEnd While With"
- functions="Abs Array Asc Atn CBool CByte CCur CDate CDbl CInt CLng CSng CStr Chr Cos CreateObject Date DateAdd DateDiff DatePart DateSerial DateValue Day Escape Eval Exp Filter Fix FormatCurrency FormatDateTime FormatNumber FormatPercent GetLocale GetObject GetRef Hex Hour InStr InStrRev InputBox Int IsArray IsDate IsEmpty IsNull IsNumeric IsObject Join LBound LCase LTrim Left Len LoadPicture Log Mid Minute Month MonthName MsgBox Now Oct Randomize RGB RTrim Replace Right Rnd Round ScriptEngine ScriptEngineBuildVersion ScriptEngineMajorVersion ScriptEngineMinorVersion Second SetLocale Sgn Sin Space Split Sqr StrComp StrReverse String Tan Time TimeSerial TimeValue Timer Trim TypeName UBound UCase Unescape VarType Weekday WeekdayName Year"
- constants="vbBlack vbRed vbGreen vbYellow vbBlue vbMagenta vbCyan vbWhite vbBinaryCompare vbTextCompare vbSunday vbMonday vbTuesday vbWednesday vbThursday vbFriday vbSaturday vbUseSystemDayOfWeek vbFirstJan1 vbFirstFourDays vbFirstFullWeek vbGeneralDate vbLongDate vbShortDate vbLongTime vbShortTime vbObjectError vbOKOnly vbOKCancel vbAbortRetryIgnore vbYesNoCancel vbYesNo vbRetryCancel vbCritical vbQuestion vbExclamation vbInformation vbDefaultButton1 vbDefaultButton2 vbDefaultButton3 vbDefaultButton4 vbApplicationModal vbSystemModal vbOK vbCancel vbAbort vbRetry vbIgnore vbYes vbNo vbCr vbCrLf vbFormFeed vbLf vbNewLine vbNullChar vbNullString vbTab vbVerticalTab vbUseDefault vbTrue vbFalse vbEmpty vbNull vbInteger vbLong vbSingle vbDouble vbCurrency vbDate vbString vbObject vbError vbBoolean vbVariant vbDataObject vbDecimal vbByte vbArray WScript Err"
- replacedwords=reservedwords&" "&functions&" "&constants&" "&specialwords
- operators="Mod Eqv And Not Or Xor Is Imp"
- sym=split("+ / \ < > = <= >= <> ( ) * -"," ")
- symto=split("@add@ @div@ @extdiv@ @lt@ @gt@ @eq@ @ngt@ @nlt@ @neq@ @lb@ @rb@ @mul@ @sbt@"," ")
- Class formatcode
- Private Sub Class_Initialize()
- End Sub
- Public Function word(code)
- Dim strings,comments
- With New RegExp
- .global=True
- .ignorecase=True
- 'space
- .pattern="[ ]"
- code=.replace(code," ")
- 'STRING
- .pattern=""".*?"""
- Set strings=.execute(code)
- code=.Replace(code,"@0String0@")
- 'COMMENT
- .pattern="('|rem\s).*"
- Set comments=.execute(code)
- code=.replace(code,"@comment@")
- 'RESERVEDWORD
- for i=0 to ubound(sym)
- code=replace(code,sym(i),symto(i))
- next
- For Each w In Split(uselesswords," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=uselesswords>" & w & "</span>$2")
- Next
- For Each w In Split(functions," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=functions>" & w & "</span>$2")
- Next
- For Each w In Split(constants," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=variants>" & w & "</span>$2")
- Next
- For Each w In Split(reservedwords," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=reservedwords>" & w & "</span>$2")
- Next
- For Each w In Split(specialwords," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=specialwords>" & w & "</span>$2")
- Next
- For Each w In Split(operators," ")
- .pattern = "(\b)" & w & "(\b)"
- code = .replace(code, "$1<span c_lass=operators>" & w & "</span>$2")
- Next
- For Each s In strings
- code=Replace(code,"@0String0@","<span c_lass=string>"&s&"</span>",1,1)
- Next
- For Each c In comments
- code=Replace(code,"@comment@","<span c_lass=comment>"&c&"</span>",1,1)
- Next
- for i=0 to ubound(sym)
- code=replace(code,symto(i),"<span class=operators>"&sym(i)&"</span>")
- next
- code=Replace(code,"c_lass","class")
- word=code
- End with
- End Function
- Function Space(code)
- variate="([a-zA-Z][a-zA-Z0-9_]*|\[[a-zA-Z0-9_]*\]|-?[0-9]+|"".*?"")"
- lspace=replace(code,ltrim(code),"")
- code=ltrim(code)
- if rtrim(code)<>code then rspace=1
- code=rtrim(code)
- With New RegExp
- .Global = True
- .IgnoreCase = True
- .pattern=""".*?"""
- Set strings=.execute(code)
- code=.Replace(code,"@String@")
- .pattern="('|rem\s).*"
- Set comments=.execute(code)
- code=.replace(code,"@comment@")
- .Pattern = "[ ]*(=|<|>|\+|&|\*|/|\^|\\)[ ]*"
- code = .Replace(code, " $1 ")
- .Pattern = "[ ]*<\s*>[ ]*"
- code = .Replace(code, " <> ")
- .Pattern = "[ ]*<\s*=[ ]*"
- code = .Replace(code, " <= ")
- .Pattern = "[ ]*>\s*=[ ]*"
- code = .Replace(code, " >= ")
- '.Pattern = "[ ]*_[ ]*$"
- 'code = .Replace(code, " _")
- .Pattern = "Do[ ]+(While|Until)[ ]*"
- code = .Replace(code, "Do $1")
- .Pattern = "End[ ]+(Sub|Function|If|Select|With|Class)[ ]*"
- code = .Replace(code, "End $1")
- .Pattern = "Select[ ]+Case[ ]+"&variate
- code = .Replace(code, "Select Case $1")
- .Pattern = "If[ ]+(.*?)[ ]+Then[ ]+(.*)$"
- code = .Replace(code, "If $1 Then $2")
- .pattern="for[ ]+"&variate&"[ ]+=[ ]+"&variate&"[ ]+to[ ]+"&variate
- code=.replace(code,"For $1 = $2 To $3")
- .pattern="for[ ]+each[ ]+"&variate&"[ ]+in[ ]+"&variate
- code=.replace(code,"For Each $1 In $2")
- For Each s In strings
- code=Replace(code,"@String@",s,1,1)
- Next
- For Each c In comments
- code=Replace(code,"@comment@",c,1,1)
- Next
- code=lspace&code
- if rspace=1 then code=code&" "
- End With
- Space=code
- End function
- End Class
- Set format=New formatcode
- function getleftspace(str)
- getleftspace=replace(str,ltrim(str),"")
- end function
复制代码
作者: jyswjjgdwtdtj 时间: 2023-5-17 20:16
以前瞎胡写的 用着着了个高亮
Class math
Public Function add(ByVal number1,ByVal number2)
len1 = Len(number1):len2 = Len(number2)
char1 = stringtochar(number1):char2 = stringtochar(number2)
Dim result,remainder
result = "":remainder = 0
Do While(len1 >= 1 Or len2 >= 1)
Dim n1,n2
If (len1 >= 1) Then
n1 = char1(len1):len1 = len1-1
Else
n1 = 0
End If
If (len2 >= 1) Then
n2 = char2(len2):len2 = len2-1
Else
n2 = 0
End If
num = CDbl(n1) + CDbl(n2) + CDbl(remainder)
remainder = (num-(num Mod 10)) / 10
result = result & (num Mod 10)
Loop
If remainder > 0 Then result = result
add = StrReverse(result)
End Function
Public Function substract(ByVal number1,ByVal number2)
r_s = numbercompare(number1,number2)
If r_s = 0 Then substract = 0
If r_s = -1 Then change number1,number2
len1 = Len(number1):len2 = Len(number2)
char1 = stringtochar(number1):char2 = stringtochar(number2)
Dim borrow,result
Do While (len1 >= 1 Or len2 >= 1)
If (len1 >= 1) Then
n1 = char1(len1):len1 = len1-1
Else
n1 = 0
End If
If (len2 >= 1) Then
n2 = char2(len2):len2 = len2-1
Else
n2 = 0
End If
num = CDbl(n1)-CDbl(n2) + CDbl(borrow)
If num < 0 Then
borrow = (num-(num Mod 10)) / 10
result = result & (num + 10)
Else
borrow = 0
result = result
End If
Loop
For i = 2 To Len(result)
If Right(result,1) = "0" Then
result = Mid(result,1,Len(result)-1)
Else
Exit For
End If
Next
result = StrReverse(result)
If r_s = -1 Then result = "-"
substract = result
End Function
Private Function stringTochar(ByVal str)
Dim char():ReDim char(0):char(0) = Chr(0)
For i = 1 To Len(str)
ReDim Preserve char(UBound(char) + 1)
char(UBound(char)) = Mid(str,i,1)
Next
stringtochar = char
End Function
End Class
Set m = New math
MsgBox m.multiply("1111111","2222")
作者: jyswjjgdwtdtj 时间: 2023-5-21 21:18
本帖最后由 jyswjjgdwtdtj 于 2023-5-21 21:30 编辑
链接:https://pan.baidu.com/s/1bhe9Fc-p1refRaAR83kOnQ?pwd=1111
提取码:1111
添加了保存 另存为 新建 打开 按钮
如果exec碰上无线循环控制台输出会卡死 不论多慢输出一次 不知道该怎么解决
作者: segree 时间: 2023-8-12 15:28
原来最近你在忙着搞这个,链接呢?快放上来,按上面代码做不太好用啊,
作者: jyswjjgdwtdtj 时间: 2023-8-12 16:42
回复 22# segree
诶呀 要体验去整个ace.js呀
作者: wwdzcdb 时间: 2023-11-6 17:15
回复 21# jyswjjgdwtdtj
链接失效了 求补
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |