AutoKey - 如何让它每隔一段时间发送一条消息

AutoKey - 如何让它每隔一段时间发送一条消息

如何配置 AutoKey 使其能够以 5 秒为间隔发送特定的句子?

那么,如果我想在离开游戏聊天时每 5 秒输入一次“你好!”,我该怎么做呢?

答案1

小心那个频率。你可能会被聊天垃圾信息/机器人禁止。

import time

# Retrieve current or set initial value.
try:
    # Toggle the value if it already exists. True <-> False
    store.set_global_value("helloRepeat",not store.get_global_value("helloRepeat"))
except:
    # Value did not exist, set it True now.
    store.set_global_value("helloRepeat",True)

# Loop de loop.
# This will not execute on toggle-off key-press.
# Existing loop from previous key-press will terminate.
while store.get_global_value("helloRepeat"):
    # Set chat and channel trigger/characters appropriately.
    keyboard.send_keys('<enter>Hello!<enter>')
    # Sleep for seconds..
    time.sleep(5)

相关内容