我的百度空间 我的51CTO空间 我的163空间

[au3]cnblogs里的au3代码高亮。

代码里面竟然没有au3的高亮。运行效果如下。

 #NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\windows\system32\SHELL32.dll|-3
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
$g_szVersion = "runas soft onepc"
If WinExists($g_szVersion)  Then
    Exit
EndIf
AutoItWinSetTitle($g_szVersion)
Global $pathname
If $CmdLine[0] = 0 Then ;没有命令行
    $pathname="cmd.exe"
Else
    $pathname=$CmdLine[1] ;有一个命令行
EndIf
If IsAdmin() Then ;有管理员权限
    Run($pathname;直接运行
Else
    _RunSoft($pathname)
EndIf
Func _RunSoft($npath)
Local $k
$k = _RunasSoft($npath)
If $k = 0 Then
    MsgBox(0,"ERROR","运行不了,请联系管理员!")
EndIf
EndFunc
Func _RunasSoft($path = "cmd.exe") ;返回0表示运行失败
    Local $password[4]
    Local $i,$result
    Local $admin = "administrator"
    $password[0]="123"
    $password[1]="234"
    $password[2]="345"
    $password[3]="xx"&StringLower(@ComputerName)
        For $i = 0 To 3
            ;MsgBox(0,"",$password[$i])
            $result = RunAs($admin@ComputerName$password[$i], 1, $path)
            If $result<>0 Then
                Return $result
            EndIf
        Next
    Return 0
EndFunc  ;==>_RunasSoft

 

高亮代码,简单的着色。  加了空格缩进

#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\myziliao\au3\regrx\regexstring.kxf
$Form1 = GUICreate("代码高亮 - by onepc", 591, 362, 203, 160)
$Group1 = GUICtrlCreateGroup("代码", 8, 16, 569, 305)
$Edit1 = GUICtrlCreateEdit("", 16, 40, 553, 273)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("生成", 208, 328, 75, 25)
$Button2 = GUICtrlCreateButton("退出", 296, 328, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_HightLine()

Case $Button2

Exit
EndSwitch
WEnd



Func _HightLine()
$code=StringSplit(GUICtrlRead($Edit1),@CRLF)
$mathkey='(?i)(\bexit\b|\bReturn\b|\bSelect\b|\bEndSelect\b|\blocal\b|\bGlobal\b|\bif\b|\belse\b|\bendif\b|\bthen\b|\bfor\b|\bto\b|\bstep\b|\bfunc\b|\bendfunc\b|\bwhile\b|\bswitch\b|\bcase\b|\bWEnd\b|\bEndSwitch\b|\bnext\b)'
$HightCode = ''
For $i=1 To $code[0]
If $code[$i]<>'' Then
$check = StringRegExp($code[$i],';',0)
;;;;;;;;
If $check Then
$temp=StringRegExp($code[$i],'([^;]*)(?=;)(.*)',3)
$leftcode=StringRegExpReplace($temp[0],'<','&lt;')
$leftcode=StringRegExpReplace($leftcode,'>','&gt;')
$leftcode=StringRegExpReplace($leftcode,'\x20','&nbsp;')
$leftcode=StringRegExpReplace($leftcode,'\x09','&nbsp;&nbsp;&nbsp;&nbsp;')
$leftcode=StringRegExpReplace($leftcode,'(?i)(#\w+\b)','<span style="color: #F000FF;">\1</span>');<EM><FONT color=F000FF>\1</FONT></EM>
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(\[]|^)(\$\w+)(?=[-,+/*\s=&)(\[]|$)','<span style="color: #AA0000;">\1</span>')
$leftcode=StringRegExpReplace($leftcode,$mathkey,'<span style="color: #F000FF;">\1</span>');关键字 0000FF <FONT color=AA0000>\1</FONT>
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(]|^)(@\w+)(?=[-,+/*\s=&)(])','<span style="color: #FF33FF;">\1</span>');FF33FF @hour
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(]|^)(\w+)(?=\s?\()','<span style="color: #000090;">\1</span>');000090 函数()
$rightcode=StringRegExpReplace($temp[1],'<','&lt;')
$rightcode=StringRegExpReplace($rightcode,'>','&gt;')
$rightcode=StringRegExpReplace($rightcode,'(.*)','<span style="color: #009933;">\1</span>') ;注释 009933 [color=Red]aa[/color]
$HightCode &= $leftcode & $rightcode & "<BR>"

Else
;$temp=StringRegExp($code[$i],'([^;]*)(?=;)(.*)',3)
$leftcode=StringRegExpReplace($code[$i],'<','&lt;')
$leftcode=StringRegExpReplace($leftcode,'>','&gt;')
$leftcode=StringRegExpReplace($leftcode,'\x20','&nbsp;')
$leftcode=StringRegExpReplace($leftcode,'\x09','&nbsp;&nbsp;&nbsp;&nbsp;')
$leftcode=StringRegExpReplace($leftcode,'(?i)(#\w+\b)','<span style="color: #F000FF;">\1</span>'); F000FF
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(\[]|^)(\$\w+)(?=[-,+/*\s=&)(\[]|$)','<span style="color:#AA0000;">\1</span>') ;(\$\w+\b) AA0000 ;'<span style="color: #AA0000;">\1</span>')
;MsgBox(0,"变量",$leftcode)
;MsgBox(0,"#",$leftcode)
$leftcode=StringRegExpReplace($leftcode,$mathkey,'<span style="color: #0000FF;">\1</span>');关键字 0000FF
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(]|^)(@\w+)(?=[-,+/*\s=&)(])','<span style="color: #FF33FF;">\1</span>');FF33FF @hour
$leftcode=StringRegExpReplace($leftcode,'(?<=[-,;+/*\s=&)(]|^)(\w+)(?=\s?\()','<span style="color: #000090;">\1</span>');000090 函数()

$HightCode &=$leftcode & "<BR>"
EndIf
;;;;;;;;;
EndIf
Next
ClipPut($HightCode)
MsgBox(0,"提示","已复制到剪贴板!")
EndFunc




posted on 2012-01-10 17:20  心若冰清  阅读(563)  评论(0编辑  收藏  举报

导航