我试图做一些简单的剪贴板控制器,其中用户可以有几个项目复制到剪贴板时使用热键(Ctrl + Shift + Q),而不是只有一个项目时使用Ctrl + C,并且可以一次全部粘贴它们(Ctrl + Shift + W),或者直接粘贴前10个项目中的任何一个(Ctrl + Shift + 1 ... 9),另一个选项是清除剪贴板(Ctrl + Shift + ' - ')。Autoit热键不工作
问题是,它只适用于多个复制和粘贴,但然后试图进行复制操作没有任何东西被添加到缓冲区.. 我想弄明白,但找不到原因..
这里是代码:
注:这个问题应该在addToClipboard()或GETALL()我相信
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Global $clipBoard[50]=[""]
Global $counter = 0
HotKeySet("^+q","addToClipboard")
HotKeySet("^+-","emptyAll")
HotKeySet("^+w","getAll")
HotKeySet("^+1","get1")
HotKeySet("^+2","get2")
HotKeySet("^+3","get3")
HotKeySet("^+4","get4")
HotKeySet("^+5","get5")
HotKeySet("^+6","get6")
HotKeySet("^+7","get7")
HotKeySet("^+8","get8")
HotKeySet("^+9","get9")
$hGUI = GuiCreate("Clipboard Controller", 100, 100,Default,Default,$WS_SIZEBOX)
GUISetState()
Func addToClipboard()
Send ("^c")
$copied = ClipGet()
$clipBoard[Mod($counter,50)] = $copied
$counter +=1
EndFunc
Func getByIndex($i)
$statement = $clipBoard[$i]
ClipPut($statement)
Send("^v")
EndFunc
Func getAll()
$statement =""
For $i In $clipBoard
If $i <> "" Then
$statement &= $i & @CRLF
EndIf
Next
ClipPut($statement)
Send("^v")
EndFunc
Func emptyAll()
For $i=0 To 49
$clipBoard[$i]=""
Next
ClipPut("")
EndFunc
Func get1()
getByIndex(0)
EndFunc
Func get2()
getByIndex(1)
EndFunc
Func get3()
getByIndex(2)
EndFunc
Func get4()
getByIndex(3)
EndFunc
Func get5()
getByIndex(4)
EndFunc
Func get6()
getByIndex(5)
EndFunc
Func get7()
getByIndex(6)
EndFunc
Func get8()
getByIndex(7)
EndFunc
Func get9()
getByIndex(8)
EndFunc
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
已经了解您的回复,并通过[这个员额(http://stackoverflow.com/questions/7936831/convert-clipboard-to-keystroke引导) 我写了下面的代码(http://codepad.org/mqtT58Rn),但也没有工作.. –
@aur,可以通过传递“”代替函数来完全取消热键的设置,而是比使用假人。我将不得不多看看你在那里做错了什么。 – Matt