tap for one key hold for a second key

Ask gaming related questions (AHK v1.1 and older)
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

tap for one key hold for a second key

15 Dec 2018, 18:51

I asked this question some time ago and thought I had it all solved. Seemed to work fine, but turns out, this
was ONLY due to the actions I had assigned in that particular game and does not work as intended :(

Currently playing Dead Space 1 and the "G" key is for actions (picking up stuff, opening doors and the like)
Fairly often, there is a log file that can be picked up and is automatically displayed on screen. To exit this
log file, the "ESC" key is necessary. Well, I would like to make tap for "G" and hold for "ESC"

---------------------------------------------------------------
$g::
KeyWait, g, T2
if (ErrorLevel = 1)
Send, {esc}
else
Send, {esc}
KeyWait, g
return
---------------------------------------------------------------
The above is one of several attempts from the following thread in an attempt to make user timeflies code work for me to no avail.

https://autohotkey.com/boards/viewtopic ... ions#p9794

The code above is obviously flawed, but tried quite a few attempts and this is just the last one.

Any and all input is appreciated :morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: tap for one key hold for a second key

16 Dec 2018, 01:12

Hallo,
try:

Code: Select all

$g::TimeG:= A_PriorHotkey = "$g" ? TimeG : A_TickCount + 300 ;tap < 300ms
$g Up::Send,% A_TickCount < TimeG ? "g" : "{Esc}" ;sends either "g" or "{Esc}"
If you want to send either "g" or "{Esc}g", just change it.
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: tap for one key hold for a second key

16 Dec 2018, 14:45

Danke, aber es geht nicht :(

Hope I said that right, as my Google> Deutsch is a bit rusty ;)

Turns out, there are segments of game when I must use the "G" key in rapid succession. I temporarily added
a second command under this key and those times when rapid succession was required..... it did not work.
My current solution is as follows:
--------------------------------------------------------------------------
;key MButton to pick up the log-file and plays after a necessary 1 second delay
;key MButton a second time to exit log-file and gameplay returns to normal

MButton::
{
Send {g down}<-----------------------------;picks up log-file
Sleep, 100
Send {g up}
Sleep, 1000
send {n down}<-----------------------------;plays the log-file
Sleep, 100
send {n up}
sleep, 100
}
return
--------------------------------------------------------------------------
This requires a second key, but since the MButton was not programmed for anything anyway, it is the next best thing :)

A solution would still be great, as I am sure to have a use for it in the future :thumbup:

Thanks, :morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 32 guests