Hello everyone,
I'm a novice here. I just want to make a script to be able to send 2 keys with 1 key press but prevent 2nd key from being sent twice or more.
Basically, I want to remap END, to send END and DEL. However, DEL should not be send more than once every 1 sec, END needs to be send as many times as I press it.
I tried
from the documentation but it doesnt seem to do what I need it to do, cann it be done? thanks for your help.
Sending 2 keys at once and preventing multi presses
-
- Posts: 12
- Joined: 02 Aug 2019, 12:55
-
- Posts: 12
- Joined: 02 Aug 2019, 12:55
Re: Sending 2 keys at once and preventing multi presses
For some reason the if-line in its current version triggers cloudflare - also for me.
Strangely, some minor re-arrangement makes it okay. So here is your original code - slightly modified - so that it could be posted (but no answer to your question
):
Strangely, some minor re-arrangement makes it okay. So here is your original code - slightly modified - so that it could be posted (but no answer to your question

Code: Select all
~End::
if (A_TimeSincePriorHotkey > 500 or A_PriorHotkey != "~End" )
{
; Too much time between presses, so this isn't a double-press.
Send, Del
return
}
Send, End
return
- tank
- Posts: 2855
- Joined: 28 Sep 2013, 22:15
- Facebook: charlie.simmons.7334
- Google: ttnnkkrr
- GitHub: ttnnkkrr
- Location: Irving TX
- Contact:
Re: Sending 2 keys at once and preventing multi presses
Sorry about the posting issue it has just been resolved
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank

Re: Sending 2 keys at once and preventing multi presses
Thanks, @tank, for fixing it.
@Aggronaught, you might want to try this:
A_tickcount is a built-in variable that returns the time in milliseconds since the system started.
Special keys like Del need to be put between { }, if you want to send them.
The ~ modifier makes sure that the End key is sent anyway with every key press.
@Aggronaught, you might want to try this:
Code: Select all
last_del := 0 ; put this into the auto-execute section of the script (top of the script)
~End::
if ((A_tickcount - last_del) > 1000)
{
last_del := A_tickcount
Send, {Del}
}
return
Special keys like Del need to be put between { }, if you want to send them.
The ~ modifier makes sure that the End key is sent anyway with every key press.
-
- Posts: 12
- Joined: 02 Aug 2019, 12:55
Re: Sending 2 keys at once and preventing multi presses
thank you, is there anyway to check if DELETE key has been pressed manually? I run into the problem where I press DELETE manually because the script is either slow/too fast..I would like to keep the script but be able to check for manual DELETE press on top of the scripted press.gregster wrote: ↑10 Aug 2019, 23:37Thanks, @tank, for fixing it.
@Aggronaught, you might want to try this:A_tickcount is a built-in variable that returns the time in milliseconds since the system started.Code: Select all
last_del := 0 ; put this into the auto-execute section of the script (top of the script) ~End:: if ((A_tickcount - last_del) > 1000) { last_del := A_tickcount Send, {Del} } return
Special keys like Del need to be put between { }, if you want to send them.
The ~ modifier makes sure that the End key is sent anyway with every key press.
so it would work like this
When i press END,
it sends END everytime
only sends DELETE every 1 secs
but if it would check if I had pressed DELETE manually in the last second and if i had pressed DELETE manually in the previous second, it won't send DELETE again.
thanks a lot again.
Re: Sending 2 keys at once and preventing multi presses
If I understand correctly, this small change might help:
Code: Select all
last_del := 0 ; put this into the auto-execute section of the script (top of the script)
~Del::last_del := A_tickcount
~End::
if ((A_tickcount - last_del) > 1000)
{
last_del := A_tickcount
Send, {Del}
}
return
-
- Posts: 12
- Joined: 02 Aug 2019, 12:55
Re: Sending 2 keys at once and preventing multi presses
works perfectly, thank you so much.