Send Key after fixed time

Get help with using AutoHotkey and its commands and hotkeys
crimzonal

Send Key after fixed time

13 Jun 2018, 20:04

Hey everyone I'm new to AHK. I've been using it for gaming mainly. Most of the in game functions I want to write I've been able to figure out on my own but I got stuck on this new function I'm trying to write. Decided to reach out into the community for help!

So basically what I want to do is for example after I hit a key 'e', it sends key 'i' but it sleeps for some duration say 600 milliseconds before being able to send 'i' again. But during that time if the key 'e' is pressed, it sends 'i' after the 600 milliseconds is up. If not pressed then nothing sends.

The current function that I have is a simple

please place your code in [code][/code] tags!

The only problem with this is, if i hit key e before the 600ms is up, nothing happens, however I also do not want to hold they key. Is it possible for ahk to store my second key press before those 600ms and send 'i' again after? Thank you
Rohwedder
Posts: 1009
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send Key after fixed time

14 Jun 2018, 02:16

Hallo,
two different behaviors!
This:

Code: [Select all] [Download] GeSHi © Codebox Plus

e:: ;storing a second key 'e' press
Sleep, NextI - A_TickCount
Sendinput, i
NextI := A_TickCount + 600
Return
or that:

Code: [Select all] [Download] GeSHi © Codebox Plus

e:: ;only send if key 'e' is pressed
If (NextI < A_TickCount)
{
Sendinput, i
NextI := A_TickCount + 600
}
Return

Return to “Ask For Help”

Who is online

Users browsing this forum: mshafer1, Sparkon, Zurydix and 28 guests