AutoHotkey - 构建剪贴板保存功能
AutoHotkey - Building a Clipboardsaving Function
我想做的是构建一个函数,我可以用它来粘贴一些东西(在本例中是 URL)。通常我只会使用发送命令或发送命令,但它们有点慢,有点烦人。这就是为什么我想避免它并改用剪贴板。
这里是我的函数:
ClipPaster(CustomClip){
ClipSaved := ClipboardAll ;Saving the current clipboard
Clipboard := %CustomClip% ;Overwriting the current clipboard
Send, ^{v}{Enter} ;pasting it into the search bar
Clipboard := Clipsaved ;Recovering the old clipboard
}
下面是我如何使用函数:
RAlt & b::
Send, ^{t} ;Open a new tab
ClipPaster("chrome://settings/content/images") ;Activating my clipboard
return
RAlt & g::
Send, ^{t} ;Open a new tab
ClipPaster("https://translate.google.com/#en/es/violin") ;Activating
my clipboard function
return
然后当我尝试使用该功能时。我得到一个错误:
错误:以下变量名称包含非法字符:"chrome://settings/content/images"
线:
-->1934: 剪贴板 := %CustomClip%
我做错了什么?
您收到此错误消息是因为
Variable names in an expression are NOT enclosed in percent signs.
https://www.autohotkey.com/docs/Variables.htm#Expressions
ClipPaster(CustomClip){
ClipSaved := ClipboardAll ; Saving the current clipboard
Clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
; Variable names in an expression are NOT enclosed in percent signs:
Clipboard := CustomClip ; Overwriting the current clipboard
ClipWait 1 ; wait max. 1 second for the clipboard to contain data
if (!ErrorLevel) ; If NOT ErrorLevel clipwait found data on the clipboard
Send, ^v{Enter} ; pasting it into the search bar
Sleep, 300
Clipboard := Clipsaved ; Recovering the old clipboard
ClipSaved := "" ; Free the memory
}
https://www.autohotkey.com/docs/misc/Clipboard.htm#ClipboardAll
我想做的是构建一个函数,我可以用它来粘贴一些东西(在本例中是 URL)。通常我只会使用发送命令或发送命令,但它们有点慢,有点烦人。这就是为什么我想避免它并改用剪贴板。
这里是我的函数:
ClipPaster(CustomClip){
ClipSaved := ClipboardAll ;Saving the current clipboard
Clipboard := %CustomClip% ;Overwriting the current clipboard
Send, ^{v}{Enter} ;pasting it into the search bar
Clipboard := Clipsaved ;Recovering the old clipboard
}
下面是我如何使用函数:
RAlt & b::
Send, ^{t} ;Open a new tab
ClipPaster("chrome://settings/content/images") ;Activating my clipboard
return
RAlt & g::
Send, ^{t} ;Open a new tab
ClipPaster("https://translate.google.com/#en/es/violin") ;Activating
my clipboard function
return
然后当我尝试使用该功能时。我得到一个错误: 错误:以下变量名称包含非法字符:"chrome://settings/content/images" 线: -->1934: 剪贴板 := %CustomClip%
我做错了什么?
您收到此错误消息是因为
Variable names in an expression are NOT enclosed in percent signs.
https://www.autohotkey.com/docs/Variables.htm#Expressions
ClipPaster(CustomClip){
ClipSaved := ClipboardAll ; Saving the current clipboard
Clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
; Variable names in an expression are NOT enclosed in percent signs:
Clipboard := CustomClip ; Overwriting the current clipboard
ClipWait 1 ; wait max. 1 second for the clipboard to contain data
if (!ErrorLevel) ; If NOT ErrorLevel clipwait found data on the clipboard
Send, ^v{Enter} ; pasting it into the search bar
Sleep, 300
Clipboard := Clipsaved ; Recovering the old clipboard
ClipSaved := "" ; Free the memory
}
https://www.autohotkey.com/docs/misc/Clipboard.htm#ClipboardAll