【问题标题】:How to write a script in AHK that pastes a text, waits one minute, then pastes again?如何在 AHK 中编写一个粘贴文本的脚本,等待一分钟,然后再次粘贴?
【发布时间】:2012-12-03 10:39:36
【问题描述】:

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

AHK=AutoHotKey

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

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

【问题讨论】:

    标签: wait autohotkey repeat


    【解决方案1】:

    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
    

    【讨论】:

    • 我更新了原来的问题。脚本需要按回车键。
    • 干得好,非常感谢。如果您有兴趣为我们开发,请查看github.com/folly
    【解决方案2】:
    #NoEnv
    Loop
    {
    SendInput, ^v
    Sleep, 60000
    }
    Capslock::ExitApp
    

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

    #NoEnv
    Loop
    {
    SendInput, This is the text I want to send{Enter}
    Sleep, 60000
    }
    Capslock::ExitApp
    

    【讨论】:

    • 您能否使用示例文本编辑代码,以便我知道要替换哪个部分。我猜 ^v 会从剪贴板粘贴,但我希望在代码中定义文本。
    • 有效,但仅适用于短文本,长文本似乎不起作用。我是否需要为跨越多个换行符的较长文本添加一些特殊符号,例如引号?
    • 我更新了原始问题。脚本需要按回车键。
    • 干得好,非常感谢。如果您有兴趣为我们开发,请查看github.com/folly
    猜你喜欢
    • 2023-02-04
    • 1970-01-01
    • 2022-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-25
    • 2014-05-04
    • 1970-01-01
    相关资源
    最近更新 更多