请精简该代码
本帖最后由 Evol 于 2010-7-29 17:01 编辑本人昨天写的一个用来当多次剪贴板的代码。但是总感觉数组那里调用及函数那里重复很多,但我写循环用来将数组变量重新赋值时,会提示错误。想请大侠们帮我精简一下代码,让我深入学习一下AUTOIT中数组及函数的使用方法。
Opt("TrayAutoPause",0)
HotKeySet("^{F4}", "Endme")
HotKeySet("{Pause}", "Clearme")
HotKeySet("^1", "Show1");Alt-1
HotKeySet("^2", "Show2");Alt-1
HotKeySet("^3", "Show3");Alt-1
HotKeySet("^4", "Show4");Alt-1
HotKeySet("^5", "Show5");Alt-1
HotKeySet("^6", "Show6");Alt-1
HotKeySet("^7", "Show7");Alt-1
HotKeySet("^8", "Show8");Alt-1
HotKeySet("^9", "Show9");Alt-1
HotKeySet("^0", "Show10");Alt-1
HotKeySet("^!1", "Puts1");Alt-1
HotKeySet("^!2", "Puts2");Alt-1
HotKeySet("^!3", "Puts3");Alt-1
HotKeySet("^!4", "Puts4");Alt-1
HotKeySet("^!5", "Puts5");Alt-1
HotKeySet("^!6", "Puts6");Alt-1
HotKeySet("^!7", "Puts7");Alt-1
HotKeySet("^!8", "Puts8");Alt-1
HotKeySet("^!9", "Puts9");Alt-1
HotKeySet("^!0", "Puts10");Alt-1
HotKeySet("^!c", "Bord");Alt-1
HotKeySet("^`", "ISSHow");Alt-1
Global $A=["","","","","","","","","",""]
Global $F=0,$msg,$K=-1,$S=0
Do
Sleep(500)
$msg="Ctrl+1 = " & $A & @CRLF & "Ctrl+2 = " & $A & @CRLF & "Ctrl+3 = " & $A & @CRLF & "Ctrl+4 = " & $A & @CRLF & "Ctrl+5 = " & $A & @CRLF & "Ctrl+6 = " & $A & @CRLF & "Ctrl+7 = " & $A & @CRLF & "Ctrl+8 = " & $A & @CRLF & "Ctrl+9 = " & $A & @CRLF & "Ctrl+0 = " & $A
If $S=1 Then
ToolTip($msg,0,@DesktopHeight-230,"Evol's Program , Ctrl+F4 to Exit.",0,1)
Else
ToolTip("")
EndIf
Until $F=1
Func ISShow()
If $S=1 Then
$S=0
Else
$S=1
EndIf
EndFunc
Func Bord()
Send("^c")
$K=$K+1
$A[$K]=ClipGet()
If $K=9 Then
MsgBox(16,"提示","系统剪贴板已存储满。将从第一项开始重新循环保存。")
$K=-1
EndIf
EndFunc
Func Clearme()
For $U=0 To 9
$A[$U]=""
Next
EndFunc
Func Show1()
ClipPut($A)
Send("^v")
EndFunc
Func Show2()
ClipPut($A)
Send("^v")
EndFunc
Func Show3()
ClipPut($A)
Send("^v")
EndFunc
Func Show4()
ClipPut($A)
Send("^v")
EndFunc
Func Show5()
ClipPut($A)
Send("^v")
EndFunc
Func Show6()
ClipPut($A)
Send("^v")
EndFunc
Func Show7()
ClipPut($A)
Send("^v")
EndFunc
Func Show8()
ClipPut($A)
Send("^v")
EndFunc
Func Show9()
ClipPut($A)
Send("^v")
EndFunc
Func Show10()
ClipPut($A)
Send("^v")
EndFunc
Func Puts1()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts2()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts3()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts4()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts5()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts6()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts7()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts8()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts9()
Send("^C")
$A=ClipGet()
EndFunc
Func Puts10()
Send("^C")
$A=ClipGet()
EndFunc
Func Endme()
$F=1
EndFunc 首先楼主提问的标题有问题。
其次是你的代码 Show n () Puts n ()这些自定义函数几乎都是在做相同的事,可以定义参数来完成,这样应该会简单很多的。 不知道你有没有看过帮助,键盘控制管理——HotKeySet里,
要调用一个函数 不能 给函数加上参数. 它将会被忽略.
页:
[1]