【发布时间】:2012-04-24 21:59:14
【问题描述】:
我是编写自己的 AutoHotKey 脚本的新手,所以这只是我在这里想念的一些愚蠢的东西。
脚本的目的是让用户选择一些文本并按下热键 (Win-W)。菜单弹出,他们单击菜单项。然后应将所选文本复制到剪贴板。这就是我现在想做的。
问题是它第一次工作,然后失败,然后工作,然后失败,等等。它基本上只是每隔一次工作。
我正在使用最新的AutoHotKey_l(unicode 32bit)运行 Win7 x64。
我在ClipWait 上有一个超时,它基本上只是等待,从不接收复制的文本,并发出 ErrorLevel 1。
代码如下:
#SingleInstance force
; EXAMPLE #2: This is a working script that creates a popup menu that is displayed when the user presses the Win-w hotkey.
; Create the popup menu by adding some items to it.
Menu, MyMenu, Add, Demo, Demo
return ; End of script's auto-execute section.
Demo:
clipboard = ; Start off empty to allow ClipWait to detect when the text has arrived.
Send ^c
ClipWait, 2 ; Wait for the clipboard to contain text.
if ErrorLevel = 1
{
MsgBox Copy failed
}
else
{
MsgBox Copy worked
}
return
#w::Menu, MyMenu, Show ; i.e. press the Win-w hotkey to show the menu.
任何帮助将不胜感激。
【问题讨论】:
-
我无法重现您所看到的内容。在 Win7 x64 上完全按原样使用您的脚本,我每次都看到“复制有效”。 AHK 版本 1.0.48.05。
-
你在不同的程序中试过这个吗?我想知道您是否在某个地方使用它时失去了对文本区域或其他东西的关注。
-
好吧,我知道这很愚蠢。 :) 你是对的。我一直在 Notepad++ 中进行测试,这就是问题所在。也许我有一个插件或导致问题的东西——因为我在其他一些文本编辑器(UltraEdit、写字板等)中尝试过它——它在所有这些编辑器中都完美无缺。感谢您的帮助!
-
太棒了!很高兴听到您正在取得进展。
标签: autohotkey