如何使计算机每隔X秒按一次键

image

Have you ever needed to press a key every couple of seconds, or every few minutes? Perhaps you’re playing a video game and you’re waiting for an item, or you’ve got some other reason. Either way, here’s how to make your PC do it automatically.

您是否需要每隔几秒钟或每隔几分钟按一次键? 也许您在玩电子游戏并且正在等待商品,或者还有其他原因。 无论哪种方式,这都是使您的PC自动执行操作的方法。

You’ll need to start by downloading and installing AutoHotkey, which is a simple scripting language that allows you to create easy scripts. Once you do that, right-click anywhere and choose New –> AutoHotkey Script.

您需要首先下载并安装AutoHotkey ,这是一种简单的脚本语言,可让您创建简单的脚本。 完成后,右键单击任意位置,然后选择“新建”->“自动热键脚本”。

Once you’ve done that, paste the following into the script:

完成此操作后,将以下内容粘贴到脚本中:

#Persistent SetTimer, PressTheKey, 1800000 Return

#Persistent SetTimer,PressTheKey,1800000返回

PressTheKey: Send, {Space} Return

PressTheKey:发送,{空格}返回

This simple script will wait every 30 minutes and press the Spacebar. You can adjust the 1800000 number above to the amount of milliseconds required. So, for example, if you wanted it to run every 2 minutes, you’d use 60 seconds * 2 minutes * 1000 milliseconds = 120000 total milliseconds.

这个简单的脚本将每30分钟等待一次,然后按空格键。 您可以将上面的1800000数字调整为所需的毫秒数。 因此,例如,如果您希望它每2分钟运行一次,那么您将使用60秒* 2分钟* 1000毫秒= 120000总毫秒。

(Warning: Don’t set a very low number of milliseconds. For example, if you set the time to 10 milliseconds, the script will press the Spacebar one hundred times per second, which could cause obvious problems.)

(警告:不要将毫秒数设置得太低。例如,如果将时间设置为10毫秒,脚本将每秒按空格键一百次,这可能会引起明显的问题。)

image

Save the file name as whatever you’d like, and then double-click on it to run it.

将文件名保存为所需的名称,然后双击运行它。

You can also send another hotkey or any number of characters just by changing the Send, {Space} line to something else—you can literally type out some letters you want to send, or you can use some of the special keys on the AutoHotkey documentation page. For example, to make it send the word “lazy” and then press the Space bar, you could use:

您还可以通过将Send {Space}行更改为其他内容来发送另一个热键或任意数量的字符-您可以逐字键入要发送的一些字母,也可以使用AutoHotkey文档中的某些特殊键页面 。 例如,要使其发送“ lazy”一词,然后按空格键,可以使用:

Send,lazy{Space}

发送,懒惰{Space}

I’m not entirely certain what you’ll want to use this for, but that’s what makes scripting so much fun.

我不确定您将要使用它什么,但这就是使脚本编写如此有趣的原因。

翻译自: https://www.howtogeek.com/97998/how-to-make-your-computer-press-a-key-every-x-seconds/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值