我試圖做一些簡單的剪貼板控制器,其中用戶可以有幾個項目複製到剪貼板時使用熱鍵(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