Condensing Autohotkey Code
Posted: 13 Jan 2019, 18:14
Hello Folks,
I looked around a bit and couldn't find a quick answer, maybe you know of one?
I started writing code the other day and realized that I was writing it inside more lines than necessary (due to my newness about coding and how AHK interpreter works in general)
for example, I had this code:
and "minified" it to this:
I read somewhere that combining multiple expressions into one line speeds up script performance in terms of speed, did what I do above by "minifying" my AHK code also increase my scripts speed performance? I tried to use a script that checks this but I'm too incompetent at this point to implement it correctly
Is there any way I could condense my code further (includingg on other code, not just what I posted above as an example)? Obviously Javascript has minifiers that puts everything into one line, but from my understanding, that is not possible with AHK (without some serious undertaking).
I'm wondering if anyone knows of a guide I could reference that can tell me what can go all into one line and what can't?
I'm using AHK v1.1.30.01. I haven't been able to dabble with v2 yet, but will the way code is written in v2 also help with more improved performance "one-liners" or condensed code?
Thanks a bunch for your response in advance!
I looked around a bit and couldn't find a quick answer, maybe you know of one?
I started writing code the other day and realized that I was writing it inside more lines than necessary (due to my newness about coding and how AHK interpreter works in general)
for example, I had this code:
Code: Select all
!UP::
{
try
{
Xl.Selection.Offset(-1,0).Select
}
catch e
{
}
}
return
!DOWN::
{
try
{
Xl.Selection.Offset(1,0).Select
}
catch e
{
}
} return
!LEFT::
{ try { Xl.Selection.Offset(0,-1).Select
} catch e {
}
}
return
!RIGHT::
{
try
{
Xl.Selection.Offset(0,1).Select
}
catch e
{
}
}
return
and "minified" it to this:
Code: Select all
!UP::
{ try { Xl.Selection.Offset(-1,0).Select
} catch e {
}} return
!DOWN::
{ try { Xl.Selection.Offset(1,0).Select
} catch e {
}} return
!LEFT::
{ try { Xl.Selection.Offset(0,-1).Select
} catch e {
}} return
!RIGHT::
{ try { Xl.Selection.Offset(0,1).Select
} catch e {
}} return
Is there any way I could condense my code further (includingg on other code, not just what I posted above as an example)? Obviously Javascript has minifiers that puts everything into one line, but from my understanding, that is not possible with AHK (without some serious undertaking).
I'm wondering if anyone knows of a guide I could reference that can tell me what can go all into one line and what can't?
I'm using AHK v1.1.30.01. I haven't been able to dabble with v2 yet, but will the way code is written in v2 also help with more improved performance "one-liners" or condensed code?
Thanks a bunch for your response in advance!