Small script for testing

Ask gaming related questions (AHK v1.1 and older)
Drognan
Posts: 8
Joined: 22 May 2018, 12:58

Small script for testing

22 May 2018, 13:06

Hello,

i am a new member and i have read the tutorial and the help file. There are many useful commands and i have wrote my first script, just for testing. The example with the ^j:: send, this is my first script works perfect.

What i want to do is a bit more difficult: Here is my code:

Code: Select all

^j:: 1
Sleep 250
Send {3}
Sleep 2000
Return
#::ExitApp ; schließt das Skript bei Drücken von Win (="#")

First; i want a hotkey to run the script and with # i want to close it (works). While my game is running.

In the first line i want to press the 1 from my Num pad (Num 1) doesn't work. Then the macro should wait 0,25 seconds and then it should press 3 on Num pad (don't work). The button 3 should be pressed for2 seconds (don't work). What is wrong here? I would be happy for help.

regards
Drognan
Guest

Re: Small script for testing

22 May 2018, 14:41

When you have a multi line hotkey/hotstring you need to have an enter after the :: otherwise not all commands will be executed.

Code: Select all

^j:: ; new line here
Send 1 ; see also the list of keynames https://autohotkey.com/docs/commands/Send.htm
; rest of your code ...
Drognan
Posts: 8
Joined: 22 May 2018, 12:58

Re: Small script for testing

22 May 2018, 14:49

If the Button Num1 is pressed down then the macro should wait a half second and then the Button 3 on Num pad should be pressed
Drognan
Posts: 8
Joined: 22 May 2018, 12:58

Re: Small script for testing

22 May 2018, 15:16

1::
Sleep 500
Send 3
Sleep 2000
Return
#::ExitApp ; schließt das Skript bei Drücken von Win (="#")

thanks, a bit better but not what i want. If the button 1 on my NUM pad (not the number keys) is pressed, then the 3 on NUM pad should be pressed and hold for 2 seconds, but after a waiting time of 0,5 seconds.
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: Small script for testing

22 May 2018, 15:49

Numpad1 and Numpad3 are the correct names for the numpad keys (compare https://autohotkey.com/docs/KeyList.htm#Numpad_keys).
You could do this:

Code: Select all

Numpad1::
sleep 500
Send {numpad3 down}
sleep 2000
Send {numpad3 up}
return
Not sure, if it will have the desired effect in your case, because this technique doesn't auto-repeat the Numpad3 key while held down - you will need a loop instead: https://autohotkey.com/docs/commands/Se ... Down_a_Key

Next time, please use the Ask for Help forum for a question like this, or better the Ask for Help>Gaming subforum, because sending keys to games can be different from sending it to a normal application.
This forum here is for already working scripts and functions (that have a certain originality).
Drognan
Posts: 8
Joined: 22 May 2018, 12:58

Re: Small script for testing

22 May 2018, 17:51

Thank you, sorry for posting in the wrong forum. I will try this.

regards

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 96 guests