Double tap + hold as input?

Ask gaming related questions (AHK v1.1 and older)
User avatar
CandyClout
Posts: 7
Joined: 27 Jul 2022, 13:45

Double tap + hold as input?

Post by CandyClout » 23 Mar 2023, 16:54

I'm trying to make up for what ARK left out.

I'd like to be able to tap w, release w, tap w and hold for 1 second as the input to hold down w until any of these keys are pressed: w, i, f, l, e,
I would also like it to do the same for the e key just like the w key.

I'm very confused as to how to make this input work.
I have a primitive version that just holds down w when i press CTRL+W but its far from functioning smoothly. I also couldn't figure out how to make it only work if ARK window is selected/open.

Thanks for all future help and suggestions.


[Mod action: Topic moved from "[V1] Ask for Help" since this for a game.]

User avatar
mikeyww
Posts: 26947
Joined: 09 Sep 2014, 18:38

Re: Double tap + hold as input?

Post by mikeyww » 23 Mar 2023, 19:51

Hello,

Here is a start with the W.

Code: Select all

#Requires AutoHotkey v1.1.33
app := "ahk_exe notepad.exe"

#If on
w::
i::
f::
l::
e::
Send {w up}
SoundBeep 700
on := False
Return

#If WinActive(app)
$w::
KeyWait w, T.2
If ErrorLevel {   ; Press #1: key was held
 While GetKeyState("w", "P") {
  Send w
  Sleep 20
 }
 Return
}                 ; Press #1: key was not held
KeyWait w, DT.2
If ErrorLevel {   ; Key was not pressed a second time
 Send w
 SoundBeep 1500
 Return
}                 ; Key was pressed a second time
KeyWait w, T1
If ErrorLevel {   ; Press #2: key was held for at least 1 second
 Send {w down}
 SoundBeep 2200
 KeyWait w
 on := True
 SoundBeep 900
} Else {          ; Press #2: key was not held for at least 1 second
 Send ww
 SoundBeep 2000
}
Return
#If

User avatar
CandyClout
Posts: 7
Joined: 27 Jul 2022, 13:45

Re: Double tap + hold as input?

Post by CandyClout » 26 Mar 2023, 18:19

So I've got this code below. I removed the first w from the #If on list because it said it was a duplicate, and no big deal if w isn't list there:

Code: Select all

#Requires AutoHotkey v1.1.33
app := "ahk_exe notepad.exe"

#If on
d::
i::
f::
l::
e::
x::
Send {w up}
SoundBeep 700
on := False
Return

#If WinActive(ARK: Survival Evolved)
$w::
KeyWait w, T.2
If ErrorLevel {   ; Press #1: key was held
 While GetKeyState("w", "P") {
  Send w
  Sleep 20
 }
 Return
}                 ; Press #1: key was not held
KeyWait w, DT.2
If ErrorLevel {   ; Key was not pressed a second time
 Send w
 SoundBeep 1500
 Return
}                 ; Key was pressed a second time
KeyWait w, T1
If ErrorLevel {   ; Press #2: key was held for at least 1 second
 Send {w down}
 SoundBeep 2200
 KeyWait w
 on := True
 SoundBeep 900
} Else {          ; Press #2: key was not held for at least 1 second
 Send ww
 SoundBeep 2000
}
Return
#If

But when I run it, I receive

Code: Select all

Error: Missing ")" before ":"

Line#
002: app := "ahk_exe notepade.exe
004: #If,on
005: Return
.....continues to 022.....

User avatar
CandyClout
Posts: 7
Joined: 27 Jul 2022, 13:45

Re: Double tap + hold as input?

Post by CandyClout » 26 Mar 2023, 18:35

So, It said I was using a duplicate hotkey, so I removed the w from the #If on list, which is no big deal. I also can't use the If Win Active, bc the window is "ARK: Survival Evolved" and has a ':' in it.
But when I remove both of those, it still does nothing. :(

User avatar
mikeyww
Posts: 26947
Joined: 09 Sep 2014, 18:38

Re: Double tap + hold as input?

Post by mikeyww » 26 Mar 2023, 20:37

The script that I posted generates no errors. I would like to know if it works without any changes. This tells you if you have a working starting point. If it works, the script can then be modified.

If you see an error, you can post your exact script, a screenshot of the error message, and your AHK version number.

User avatar
CandyClout
Posts: 7
Joined: 27 Jul 2022, 13:45

Re: Double tap + hold as input?

Post by CandyClout » 27 Mar 2023, 22:13

I can't use the If Win Active bc of the window name, but when I remove that, it breaks the code.

User avatar
boiler
Posts: 16963
Joined: 21 Dec 2014, 02:44

Re: Double tap + hold as input?

Post by boiler » 27 Mar 2023, 22:19

If you mean you can't use #If WinActive because of this line:

Code: Select all

#If WinActive(ARK: Survival Evolved)
...it's because your syntax is incorrect. Function parameters are always expressions, and literal strings in expressions must always be quoted:

Code: Select all

#If WinActive("ARK: Survival Evolved")

User avatar
CandyClout
Posts: 7
Joined: 27 Jul 2022, 13:45

Re: Double tap + hold as input?

Post by CandyClout » 28 Mar 2023, 13:21

That was a huge help but now I can ONLY use 'w' by using the double-tap and hold- without the ability to simply hold down w manually to move forward.

Post Reply

Return to “Gaming Help (v1)”