Using AHI.SendKeyEvent to hold down a key for a specific amount of time?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Anfly
Posts: 12
Joined: 10 Sep 2022, 16:47

Using AHI.SendKeyEvent to hold down a key for a specific amount of time?

Post by Anfly » 27 Nov 2022, 16:28

Original forum : viewtopic.php?t=45307
A bit new to this, but from my understanding, AHI.SendKeyEvent(keyboardId, GetKeySC("1"), 1) is able to send "1", but I am having troubles figuring out how i can hold "1" for a specific amount of time without using Send. Here is a part of my code :

Code: Select all

#SingleInstance force
#Persistent
#include <AutoHotInterception>

time := 200

AHI := new AutoHotInterception()
keyboardId := AHI.GetKeyboardId(0x03F0, 0x0591)

AHI.SubscribeKey(keyboardId, GetKeySC(CurrentTap), false)
hotkey, w, function ;just a testing hotkey

return

function:
AHI.SendKeyEvent(keyboardId, GetKeySC(CurrentTap), 1)
;--- perhaps a code that loops AHI.SendKeyEvent? I need to make it hold for %time% amount
return
Thank you! If it is not possible, they I may just create a loop, but I am afraid it won't go as intended

Return to “Ask for Help (v1)”