|
本帖最后由 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[10]=["","","","","","","","","",""]
Global $F=0,$msg,$K=-1,$S=0
Do
Sleep(500)
$msg="Ctrl+1 = " & $A[0] & @CRLF & "Ctrl+2 = " & $A[1] & @CRLF & "Ctrl+3 = " & $A[2] & @CRLF & "Ctrl+4 = " & $A[3] & @CRLF & "Ctrl+5 = " & $A[4] & @CRLF & "Ctrl+6 = " & $A[5] & @CRLF & "Ctrl+7 = " & $A[6] & @CRLF & "Ctrl+8 = " & $A[7] & @CRLF & "Ctrl+9 = " & $A[8] & @CRLF & "Ctrl+0 = " & $A[9]
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[0])
Send("^v")
EndFunc
Func Show2()
ClipPut($A[1])
Send("^v")
EndFunc
Func Show3()
ClipPut($A[2])
Send("^v")
EndFunc
Func Show4()
ClipPut($A[3])
Send("^v")
EndFunc
Func Show5()
ClipPut($A[4])
Send("^v")
EndFunc
Func Show6()
ClipPut($A[5])
Send("^v")
EndFunc
Func Show7()
ClipPut($A[6])
Send("^v")
EndFunc
Func Show8()
ClipPut($A[7])
Send("^v")
EndFunc
Func Show9()
ClipPut($A[8])
Send("^v")
EndFunc
Func Show10()
ClipPut($A[9])
Send("^v")
EndFunc
Func Puts1()
Send("^C")
$A[0]=ClipGet()
EndFunc
Func Puts2()
Send("^C")
$A[1]=ClipGet()
EndFunc
Func Puts3()
Send("^C")
$A[2]=ClipGet()
EndFunc
Func Puts4()
Send("^C")
$A[3]=ClipGet()
EndFunc
Func Puts5()
Send("^C")
$A[4]=ClipGet()
EndFunc
Func Puts6()
Send("^C")
$A[5]=ClipGet()
EndFunc
Func Puts7()
Send("^C")
$A[6]=ClipGet()
EndFunc
Func Puts8()
Send("^C")
$A[7]=ClipGet()
EndFunc
Func Puts9()
Send("^C")
$A[8]=ClipGet()
EndFunc
Func Puts10()
Send("^C")
$A[9]=ClipGet()
EndFunc
Func Endme()
$F=1
EndFunc |
|