Reputation: 119
How to write a script in AHK that pastes a text, waits one minute, then pastes again?
AHK=AutoHotKey
Not for spamming, it's for one of my own web projects.
I should specify: the script needs to paste a text, press return, wait one minute then paste again. If it doesn't press return it doesn't work.
Upvotes: 2
Views: 5974
Reputation: 86230
SetTimer is better than sleep for something like this.
#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
Upvotes: 2
Reputation: 59283
#NoEnv
Loop
{
SendInput, ^v
Sleep, 60000
}
Capslock::ExitApp
Press caps lock to stop pasting. For text defined in code:
#NoEnv
Loop
{
SendInput, This is the text I want to send{Enter}
Sleep, 60000
}
Capslock::ExitApp
Upvotes: 1