1 key to 2 with delay

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dx34354
Posts: 13
Joined: 14 Nov 2017, 01:08

1 key to 2 with delay

21 Jun 2018, 12:41

am i still on? testing 123.....

if yes, i need a delay or similar between alt & f, for the following script;

LAlt::
Send {LAlt down}
Send {f down}
Return

LAlt up::
Send {LAlt up}
Send {f up}
Return

it's for a game. normally, without a script, if i press alt it aims the gun. if whilst in that view, i press f, it then changes to an ironsight view. you have to press and hold two keys to get ironsights. i just want to press one key, alt, to get ironsights. i find it abhorrent and idiotic to have to press and hold two keys to achieve what most games let you via one key. okay, so i searched and found the above script and tested it. it works, kinda. if i press alt with the script, it only goes to aim view, as normal. however, if i quickly tap the alt key, it does what i want. doing that is not natural or how it should be. i am almost certain adding a delay of maybe half a second between the time alt and f "unite", should fix the issue. without a script when i do it like i am supposed to, i press alt and then a few moments later press f. if i was to press alt+f simultaneously even without the script it would not work either. so i don't actually want the script to make alt be alt+f simultaneously, i want my left alt to be alt and very shortly also accept the input of f. i want to use one key to achieve two key presses that in game, naturally, happen with a separate push for f.

so i now add a delay and tried a few different timer values;

LAlt::
Send {LAlt down}
SetKeyDelay, 1000
Send {f down}
Return

LAlt up::
Send {LAlt up}
Send {f up}
Return

i tried some, and settled on 1 second. in reality i suppose it take me one second to press alt and then whilst holding it with my finger use another finger to locate and press/hold f after. the script now works better in that the 1st alt press always goes to ironsight view. yay. except not. after that back to normal, meaning i have to quickly double tap alt to go to ironsight. i'm missing something. could the "exit" part of the script be somehow interfering?
Rohwedder
Posts: 7628
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: 1 key to 2 with delay

22 Jun 2018, 01:02

Hallo,
try this:

Code: Select all

~LAlt::
KeyWait, LAlt, T1
If ErrorLevel
{
	Send {Blind}{f DownR}
	KeyWait, LAlt
	Send {Blind}{f Up}
}
Return
or that (spares the thread of the first second):

Code: Select all

~LAlt::
SetTimer, TF, -1000
HotKey, ~LAlt, Off
Return
TF:
HotKey, ~LAlt, On
If GetKeyState("LAlt","P")
{
	Send {Blind}{f DownR}
	KeyWait, LAlt
	Send {Blind}{f Up}
}
Return
dx34354
Posts: 13
Joined: 14 Nov 2017, 01:08

Re: 1 key to 2 with delay

23 Jun 2018, 00:37

oh my dear "friend", Rohwedder. :bravo: german? then ..> :beer:

i used your 1st script and it's what i want. i actually tweaked the timer to 0.1 after some testing (0.5 and 0.3) and now it all works perfectly.


ps: are you also a gamer on pc? if yes, do you use steam? :cookie:

later edit; no answer friend? :wtf: :cry: ......fine, i was only gonna reward you with a potential steam game..

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Descolada, garry and 319 guests