AutoHotkey 扩展剪贴板
正如我们都经历过一次或多次一样,有时必须用其他内容替换剪贴板内容确实很烦人(而您只需要一次左右其他信息)。
我以为我们可以使用自动热键解决这个问题,但我不知道如何解决。
我正在考虑在热键中设置变量,例如当您按 CtrlC 时,旧的剪贴板内容将存储在 AutoHotkey 中,并且您可以通过以下方式检索旧内容按即 AltV,而普通的 CtrlV 仅返回当前剪贴板的值。
有人可以帮我解决这个问题吗?我不知道如何在 AutoHotkey 中永久存储值。
问候, Aart
编辑:
我找到了完美的剧本。我按照我想要的方式对其进行了修改。现在,您只需使用 Ctrl+C 即可继续复制,但如果您想检索某些内容,只需使用 AltLeftArrow< /kbd> 它就在那里!玩得开心;我知道我会的。 :)
控制:
- Ctrl+C >>复制
- Alt+V >>粘贴
- Alt+向左箭头 >>循环返回
- Alt+右箭头 >>向前循环
- Alt+H >>显示此消息
代码:
handleClip(action)
{
global static AddNextNum
global static GetNextNum
global static HighestNum
global static ClipArray
global static ClipArray1
global static ClipArray2
global static ClipArray3
global static ClipArray4
global static ClipArray5
global static ClipArray6
global static ClipArray7
global static ClipArray8
global static ClipArray9
global static ClipArray10
global static ClipArray11
global static ClipArray12
global static ClipArray13
global static ClipArray14
global static ClipArray15
global static ClipArray16
global static ClipArray17
global static ClipArray18
global static ClipArray19
global static ClipArray20
global static ClipArray21
global static ClipArray22
global static ClipArray23
global static ClipArray24
global static ClipArray25
global static ClipArray26
global static ClipArray27
global static ClipArray28
global static ClipArray29
global static ClipArray30
if (action = "save")
{
if (AddNextNum < 30)
{
AddNextNum += 1 ;
}
else
{
AddNextNum := 1 ;
}
if (HighestNum < 30)
{
HighestNum += 1 ;
}
GetNextNum := AddNextNum ;
ClipArray%AddNextNum% := Clipboard
}
else if ((action = "get") OR (action = "roll"))
{
if (GetNextNum != 0)
{
if (action = "roll")
{
Send, ^z
}
Clipboard := ClipArray%GetNextNum%
if (GetNextNum > 1)
{
GetNextNum -= 1 ;
}
else
{
GetNextNum := HighestNum
}
Send, ^v
}
}
else if (action = "rollforward")
{
if (GetNextNum != 0)
{
Send, ^z
if (GetNextNum < HighestNum)
{
GetNextNum += 1 ;
}
else
{
GetNextNum := 1
}
Clipboard := ClipArray%GetNextNum%
Send, ^v
}
}
else if (action = "clear")
{
GetNextNum := 0
AddNextNum := 0
HighestNum := 0
}
}
!0::
handleClip("clear")
return
^c::
suspend on
Send, ^c
suspend off
handleClip("save")
return
!v::
handleClip("get")
return
!Left::
handleClip("roll")
return
!Right::
handleClip("rollforward")
return
!H::
MsgBox Extended Clipboard controls: `r`n`r`nCtrl+C >> copy `r`nAlt+V >> paste `r`nAlt+Left Arrow >> cycle back `r`nAlt+Right Arrow >> cycle forward`r`nAlt+H >> display this message
免责声明:我自己没有编写此代码。我刚刚修改了它。原始脚本可以在此处找到。
as we all experienced one time or more, it sometimes is really annoying to have to replace your clipboard-content with other content (while you only need the other information once or so).
I thought we could solve this problem using autohotkey, but I have no clue how to.
I'm thinking about setting variables in a hotkey, like when you press CtrlC, the old clipboard-content gets stored inside AutoHotkey, and you could retrieve that old content by pressing i.e. AltV, while the normal CtrlV just returns the current value of the clipboard.
Could anyone help me with this please? I don't know how to permanently store values inside AutoHotkey.
Regards,
Aart
EDIT:
I have found the perfect script. I modified it as I wanted it to work. You can now just use Ctrl+C and carry on copying, but if you want to retrieve something, just use AltLeftArrow and it's there! Have fun with it; I know I will. :)
Controls:
- Ctrl+C >> copy
- Alt+V >> paste
- Alt+Left Arrow >> cycle back
- Alt+Right Arrow >> cycle forward
- Alt+H >> display this message
Code:
handleClip(action)
{
global static AddNextNum
global static GetNextNum
global static HighestNum
global static ClipArray
global static ClipArray1
global static ClipArray2
global static ClipArray3
global static ClipArray4
global static ClipArray5
global static ClipArray6
global static ClipArray7
global static ClipArray8
global static ClipArray9
global static ClipArray10
global static ClipArray11
global static ClipArray12
global static ClipArray13
global static ClipArray14
global static ClipArray15
global static ClipArray16
global static ClipArray17
global static ClipArray18
global static ClipArray19
global static ClipArray20
global static ClipArray21
global static ClipArray22
global static ClipArray23
global static ClipArray24
global static ClipArray25
global static ClipArray26
global static ClipArray27
global static ClipArray28
global static ClipArray29
global static ClipArray30
if (action = "save")
{
if (AddNextNum < 30)
{
AddNextNum += 1 ;
}
else
{
AddNextNum := 1 ;
}
if (HighestNum < 30)
{
HighestNum += 1 ;
}
GetNextNum := AddNextNum ;
ClipArray%AddNextNum% := Clipboard
}
else if ((action = "get") OR (action = "roll"))
{
if (GetNextNum != 0)
{
if (action = "roll")
{
Send, ^z
}
Clipboard := ClipArray%GetNextNum%
if (GetNextNum > 1)
{
GetNextNum -= 1 ;
}
else
{
GetNextNum := HighestNum
}
Send, ^v
}
}
else if (action = "rollforward")
{
if (GetNextNum != 0)
{
Send, ^z
if (GetNextNum < HighestNum)
{
GetNextNum += 1 ;
}
else
{
GetNextNum := 1
}
Clipboard := ClipArray%GetNextNum%
Send, ^v
}
}
else if (action = "clear")
{
GetNextNum := 0
AddNextNum := 0
HighestNum := 0
}
}
!0::
handleClip("clear")
return
^c::
suspend on
Send, ^c
suspend off
handleClip("save")
return
!v::
handleClip("get")
return
!Left::
handleClip("roll")
return
!Right::
handleClip("rollforward")
return
!H::
MsgBox Extended Clipboard controls: `r`n`r`nCtrl+C >> copy `r`nAlt+V >> paste `r`nAlt+Left Arrow >> cycle back `r`nAlt+Right Arrow >> cycle forward`r`nAlt+H >> display this message
DISCLAIMER: I didn't write this code myself. I just modified it. The original script can be found here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我就是这样解决的。我什至将这些值存储在一个文件中,因此它们在重新启动后保留在“内存”中......
然后对 Windows + F2 做了同样的事情...... Windows + F4
希望这会有所帮助
哦,顺便说一句,这会删除数据中的所有格式......
This is how I solved it. I even store the values in a file, so they stay in "memory" after a reboot....
Then did the same for Windows + F2 ..... Windows + F4
Hope this helps
Oh, b.t.w. this strips all formatting from your data....
我做了另一种变体,一种星际争霸风格,您可以使用 ctrl+number 将所选内容分配给一个数字,然后使用数字键盘上的数字再次访问这些内容。我想我会把它发布出来以防你想尝试一下。对我来说,访问我想要的内容比滚动历史记录更容易。感谢您在线程中提出这个问题。我已经多次考虑过这个问题,并且碰巧遇到了这个线程,它为我提供了我需要的工具
I made another variation, kind of starcraft style, where you assign the selected contents to a number using ctrl+number, and access those contents again using the number from the number pad. Figured I'd post it in case you feel like trying it out. For me, it feels easier to access the content I want rather than scrolling through the history. Thanks for bringing this up in a thread. I've thought about this many times and happened to come across this thread which gave me the tools I needed
另一个简单的脚本,它根本不会修改您的剪贴板,但让您有机会访问最后 10 个(可修改:参见第一行)剪贴板文本条目。我自己就不能再没有以下内容了。对于编程来说非常有用。
适用于:sqlite。需要:sqlite3.dll 和 class_SQLiteDB.ahk
http://pastebin.com/1weXi1eX
Another simple script which does not modify your clipboard at all, but gives you the opportunity to access your last 10 (modifiable: see first line) clipboard text entries. I myself could not live without the following anymore. More than useful for programming.
Works with: sqlite. Needed: sqlite3.dll and class_SQLiteDB.ahk
http://pastebin.com/1weXi1eX