Trying to figure out the syntax for continuous sections

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Trying to figure out the syntax for continuous sections

Post by imkira3 » 28 Jan 2023, 03:07

I'm trying to put a multi-line script onto a single line. I have tried && and `r and `n and `r `n, it looks like `r is newline but I keep getting errors no matter what I try. I can't seem to find detailed information on this anywhere. Here is the code, I'm trying to combine lines 3-7

Code: Select all

A_NumLock := "TEXT"

+NumLock::{
WinActivate "ahk_class" "Shell_TrayWnd"
ToolTip A_NumLock, 0, 1000000
Sendinput "!{Esc}"
}

SetTimer () => ToolTip(), 5000

User avatar
boiler
Posts: 16932
Joined: 21 Dec 2014, 02:44

Re: Trying to figure out the syntax for continuous sections

Post by boiler » 28 Jan 2023, 03:52

You’re trying to do something that is not allowed. I don’t see why you think using AHK’s representation of a line break character would somehow fool the interpreter into thinking they’re really separate lines.

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Trying to figure out the syntax for continuous sections

Post by imkira3 » 28 Jan 2023, 03:57

I'm used to using one line per bind, it's easy to organize. I was hoping to find a simple method to do so, and why would I not think a character that's meant to represent a line break would act as one? I do something similar in Notepad++ using \r\n

User avatar
boiler
Posts: 16932
Joined: 21 Dec 2014, 02:44

Re: Trying to figure out the syntax for continuous sections

Post by boiler » 28 Jan 2023, 03:58

OK. Well, it doesn’t.

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Trying to figure out the syntax for continuous sections

Post by imkira3 » 28 Jan 2023, 04:00

Then I will try and find another method that works

User avatar
boiler
Posts: 16932
Joined: 21 Dec 2014, 02:44

Re: Trying to figure out the syntax for continuous sections

Post by boiler » 28 Jan 2023, 04:01

There isn’t one. As I said, it’s not allowed.

You could make an expression where you call several functions in the same line, but that’s not the same as combining lines into one.

Example:

Code: Select all

Tab::MsgBox("Hello..."), MsgBox("world")
…but that not combining lines in general. You couldn’t combine loops, code blocks, etc., this way.

imkira3
Posts: 84
Joined: 10 Jan 2023, 13:57
Contact:

Re: Trying to figure out the syntax for continuous sections

Post by imkira3 » 28 Jan 2023, 04:13

boiler wrote:
28 Jan 2023, 04:01
There isn’t one. As I said, it’s not allowed.

You could make an expression where you call several functions in the same line, but that’s not the same as combining lines into one.
That sounds promising, and it might save space too. I don't mind having supplemental code above or below the list of binds, like how line 1 sets the text variable. That's important for user customization. All I'm trying to do is have the list of binds compacted. Right now it looks like this:

Code: Select all

NumpadDiv::^z
^NumpadDiv::numpaddiv
!NumpadDiv::^numpad1
<#NumpadDiv::launch_app1
>#NumpadDiv::launch_app1
NumpadMult::^y
^NumpadMult::numpadmult
!NumpadMult::^numpad2
<#NumpadMult::Run "C:\Users\%A_UserName%"&&"C:\Users\" A_UserName ""
>#NumpadMult::Run "C:\Users\%A_UserName%"&&"C:\Users\" A_UserName ""
NumpadSub::^s
^NumpadSub::numpadsub
!NumpadSub::^numpad3
<#NumpadSub::launch_app2
>#NumpadSub::launch_app2
...
I like it like this, keeps things organized on several levels, but if the Shift section is gonna eat up 5 lines for each button that's gonna fluff it out, I'll have to scroll a lot more while I work. It seems like a small thing, but it can be a big deal as code gets bigger. I was working on this one code that had about 60,000 files, I couldn't even edit it without bulk replace tools, it was too big so I became really organized because I had to.

Post Reply

Return to “Ask for Help (v2)”