I'm new to writing my own AutoHotKey scripts so this just has to be something stupid I'm missing here.
The intent of the script is for the user to select some text and press the hot-key (Win-W). The menu pops-up and they click the menu item. The selected text should then be copied to the clipboard. That's all i'm trying to do right now.
The problem is that it works the first time, then fails, then works, then fails, etc. It basically only works every other time.
I'm running Win7 x64 with the latest AutoHotKey_l
(unicode 32bit).
I have a timeout on the ClipWait
, and it basically just waits, never receives the copied text, and issues an ErrorLevel 1.
Here's the code:
#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.
Any help would be greatly appreciated.