simulate key pressed down

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

simulate key pressed down

10 Aug 2018, 08:21

Hi,

the thing is this:
if you open notepad, press any character, keep it pressed down, its displayed value is repeatedly displayed.

I would like to script this behaviour in AutoHotKey.

So far I've created this:

Code: Select all

^j::
Run, Notepad.exe
sleep, 1000
SetKeyDelay, 0, 30000
send, d
When I run it, Notepad is started, the d key pressed, but it's only displayed once. It's keypress is not hold down. Could anyone help me solving this?

Thanks,
Mathijs
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: simulate key pressed down

10 Aug 2018, 15:23

Hallo,
see: https://autohotkey.com/docs/commands/Se ... Down_a_Key
only held down:

Code: Select all

^j::
Run, Notepad.exe
sleep, 1000
send, {d Down}
Sleep, 30000
send, {d Up}
Return
with auto-repeat:

Code: Select all

^j::
Run, Notepad.exe
sleep, 1000
Now := A_TickCount
While, (A_TickCount - Now) < 30000
{
	Send, {d Down}
	Sleep 30
}
send, {d Up}
Return
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: simulate key pressed down

13 Aug 2018, 10:01

Rohwedder wrote:Hallo,
see: https://autohotkey.com/docs/commands/Se ... Down_a_Key
only held down:

Code: Select all

^j::
Run, Notepad.exe
sleep, 1000
send, {d Down}
Sleep, 30000
send, {d Up}
Return
with auto-repeat:

Code: Select all

^j::
Run, Notepad.exe
sleep, 1000
Now := A_TickCount
While, (A_TickCount - Now) < 30000
{
	Send, {d Down}
	Sleep 30
}
send, {d Up}
Return
I tried both approaches. First one doesn't repeat the key. The second one does , which is fine. Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus and 238 guests