I need help to make a simple script

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
vegetablesoup39
Posts: 2
Joined: 01 Apr 2023, 04:37

I need help to make a simple script

Post by vegetablesoup39 » 01 Apr 2023, 04:41

Hello, i want to create a script where you press down a specific button, and then a message is sent, and then you press down on the same button, and the next message in the list is sent.

eg. press [shift + q] and then the first message from a list is sent, like "hello there!"

and then press [shift + q] again, and then the second message from the list is sent, like 'how are you?"

Any help would be much appreciated. thank you!

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

Re: I need help to make a simple script

Post by mikeyww » 01 Apr 2023, 06:29

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0
msg := ['Hello, there!', 'How are you?']

+q:: {
 Static n := msg.Length
 SendText msg[n := n++ - msg.Length ? n : 1]
}

vegetablesoup39
Posts: 2
Joined: 01 Apr 2023, 04:37

Re: I need help to make a simple script

Post by vegetablesoup39 » 01 Apr 2023, 06:47

Hi, what if i wanted to press enter after each message eg. hello, there [press enter]

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

Re: I need help to make a simple script

Post by mikeyww » 01 Apr 2023, 07:01

Code: Select all

#Requires AutoHotkey v2.0
msg := ['Hello, there!', 'How are you?']

+q:: {
 Static n := msg.Length
 SendText msg[n := n++ - msg.Length ? n : 1] '`n'
}

Post Reply

Return to “Ask for Help (v2)”