2

如何在 AHK 中编写一个粘贴文本的脚本,等待一分钟,然后再次粘贴?

AHK=AutoHotKey

不是为了垃圾邮件,而是为了我自己的一个网络项目。

我应该指定:脚本需要粘贴文本,按回车键,等待一分钟然后再次粘贴。如果它不按回车,它就不起作用。

4

2 回答 2

2

对于这样的事情,SetTimer 比 sleep 更好。

#Persistent

; Put this wherever you want, like inside a hotkey
; Either set the clipboard to some text, or just remove this
; to use what's already there
Clipboard = This is some text to paste
SendInput ^v{Enter}
last_text := Clipboard
SetTimer, RePaste, 60000
return

RePaste:
; The clipboard can change in a minute, right?
; so we use the text we had before
tmp := clipboard
Clipboard := last_text
SendInput ^v{Enter}

; And restore what the user had
Clipboard := tmp
return

; Put this somewhere, like in a hotkey, to turn off the timer
SetTimer, RePaste, off
于 2012-12-02T11:03:30.177 回答
1
#NoEnv
Loop
{
SendInput, ^v
Sleep, 60000
}
Capslock::ExitApp

按大写锁定停止粘贴。对于代码中定义的文本:

#NoEnv
Loop
{
SendInput, This is the text I want to send{Enter}
Sleep, 60000
}
Capslock::ExitApp
于 2012-12-01T14:55:15.363 回答