how to make arrow keystrokes??? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
plshelp56735
Posts: 3
Joined: 01 Apr 2023, 15:01

how to make arrow keystrokes???

Post by plshelp56735 » 01 Apr 2023, 15:06

i have been trying for the past few hours to make a program in ahk that presses the up arrow for 1 second and then presses the down arrow for 1 second until the program is stopped. i have no idea what to do and recently lost the code i was working on, so now im asking for help. please, if you know how to do this, i would love to know how.

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

Re: how to make arrow keystrokes???

Post by mikeyww » 01 Apr 2023, 15:29

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0
SoundBeep 1500
SetKeyDelay 50
Loop
 For each, key in ['Up', 'Down'] {
  end := A_TickCount + 1000
  While A_TickCount < end
   SendEvent '{' key '}'
 }

plshelp56735
Posts: 3
Joined: 01 Apr 2023, 15:01

Re: how to make arrow keystrokes???

Post by plshelp56735 » 01 Apr 2023, 17:49

sorry for late respone i went back to trying to make my own code lol also thank you for helping!
this is what i made

Code: Select all

;::p
loop {
	send {up}
	sleep 700
	send {down}
	sleep 700
}
[Mod edit: [code][/code] tags added.]

for some reason both your code and mine dont work in the emulator im using even when its in focus.
i dont even know how to make it only activate on shift+p
sorry for asking again but could you help?

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

Re: how to make arrow keystrokes???  Topic is solved

Post by mikeyww » 01 Apr 2023, 18:25

Before you go to the emulator, I would test the script in Notepad, to see if it works there. That tells you if you have a working starting point.

Below is an alternative that holds the keys instead of pressing them repeatedly.

Code: Select all

#Requires AutoHotkey v2.0
SoundBeep 1500
Loop
 For each, key in ['Up', 'Down']
  Send('{' key ' down}'), Sleep(1000), Send('{' key ' up}')

plshelp56735
Posts: 3
Joined: 01 Apr 2023, 15:01

Re: how to make arrow keystrokes???

Post by plshelp56735 » 01 Apr 2023, 18:56

really sorry for the late response!!!
it worked! thanks you so much!!!

Post Reply

Return to “Ask for Help (v2)”