如何使计算机每隔X秒按一次键
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毫秒,腳本將每秒按空格鍵一百次,這可能會引起明顯的問題。)
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/
總結
以上是生活随笔為你收集整理的如何使计算机每隔X秒按一次键的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端第一课
- 下一篇: 计算机的组成及其功能