【发布时间】:2012-12-03 10:39:36
【问题描述】:
如何在 AHK 中编写一个粘贴文本的脚本,等待一分钟,然后再次粘贴?
AHK=AutoHotKey
不是为了垃圾邮件,而是为了我自己的一个网络项目。
我应该指定:脚本需要粘贴文本,按回车键,等待一分钟然后再次粘贴。不按回车就不行。
【问题讨论】:
标签: wait autohotkey repeat
如何在 AHK 中编写一个粘贴文本的脚本,等待一分钟,然后再次粘贴?
AHK=AutoHotKey
不是为了垃圾邮件,而是为了我自己的一个网络项目。
我应该指定:脚本需要粘贴文本,按回车键,等待一分钟然后再次粘贴。不按回车就不行。
【问题讨论】:
标签: wait autohotkey repeat
SetTimer 比睡眠更好。
#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
【讨论】:
#NoEnv
Loop
{
SendInput, ^v
Sleep, 60000
}
Capslock::ExitApp
按大写锁定停止粘贴。对于代码中定义的文本:
#NoEnv
Loop
{
SendInput, This is the text I want to send{Enter}
Sleep, 60000
}
Capslock::ExitApp
【讨论】: