Peppa Papa
Peppa Papa

Reputation: 95

Having text parameters on seperate lines of code for AHK MsgBox

I've run into a small problem with my current script. Which is hilarious because I've only just started making it, but I digress. I'm trying to make an AHK that simply tells me all of my hotkeys through a MsgBox. Therefore, I would like to have each and every command listed on their own line of code. I'll put what I mean right below.

As of right now, I have this:

1| AppsKey & H::
2|     MsgBox, 4, Commands, {
3|         Apps + H - Opens this help box `n
4|         Apps + C - Opens something. `n
5|         Apps + P - Opens something else `n
6|         Apps + T - Opens one more thing
7|         }
8|
9| Return

And, sadly, this doesn't work and returns with an error stating:

Line Text: Apps + H - Opens this help box `n
Error: This line does not contain a recognized action

I've tried using parenthesis, curly braces, and quotes so far. And am wondering whether it is even possible to have a text parameter throughout separate lines of code. If not, would I need to/should I use a GUI for that? Perhaps I might just be a bit fussy but I have many hotkeys I need to list, so hopefully, I can keep it somewhat organized so it doesn't give me a migraine next time I add more commands.

I've looked through some of AHK's examples and some google but most of the results are just explaining that Text`nMoreText makes a new line in the MsgBox itself. And the similar questions are unrelated to AHK or MsgBox. So I appreciate the help.

And, as always, thanks for taking the time to read this, and I appreciate any and all answers. If you have any questions or feel like asking for elaboration, please feel free to. Thanks once more for your time.

Upvotes: 0

Views: 412

Answers (1)

Relax
Relax

Reputation: 10603

To split a parameter of a command (in this case the MsgBox command) into more than one line you need to use a continuation section:

AppsKey & h:: ; do not use capital letters in hotkey definitions. They produce a different effect in some programs
text =
(
Apps + H - Opens this help box `n
Apps + C - Opens something. `n
Apps + P - Opens something else `n
Apps + T - Opens one more thing
)
MsgBox,, Commands, %text%
Return

Upvotes: 1

Related Questions