Autohotkey vs. AutoIt
View this topic | Back to topic list
Posted by Fredy
Sep 1, 2012 at 03:05 PM
Spicing your Outliner up : Autohotkey vs. AutoIt ; both better than Macro Tools
Whenever I buy something of extended use, I do some comparison of the various offerings (for cars, in my price range; in computing in my range of what I find useful for me, and trying to minimize price considerations - if something is “worth” it, I buy it, even if it’s (not TOO much) overpriced; sorry, no iBuys yet, in application of this rule though).
The same goes for macro tools and script languages, where you have the additional problem of the TOC being multiple times any purchase price, and in many cases, you simply cannot evaluate the real power of some such language easily.
So I made another mistake recently, hence my writing here.
I
Do NOT buy any traditional macro tool. There are many of these out there, but most of them share a common problem: Either there is no flow of control processing at all, or the flow of control elements are much too basic:
- application scope? that’s all you’ll get, at most, with most of them
- control scope? absent in almost every one of them (= in an outliner, are you in the tree or in your content field? this control scope alone will open a wholly new world for you if it’s available to you)
- if, elseif, else? some macro tools offer SOME of this, but mostly in a way that will make you write awful code, doing the same 20 or 50 code lines again and again, i.e. no substructures, let alone adaptable ones
- while, for, loops in general? forget it, for most of them
- variables? sometimes; global variables? forget them, for most of the offerings
- string processing? forget it, for most of them
And “getting out” your macros, out of these tools, is a nightmare, i.e. at best for most of them, you’ll do screenshots of your steps displayed there, print these out, then enter manually all this stuff, step for step, into your “new” tool.
SOME macro tools DO offer most or all of this, though, but then, they are proprietary macro languages, offen very buggy (and having been buggy for years, without any real solution to all this) - and do they allow for free installations, i.e. the sharing of your macros with people that didn’t buy that specific tool first?! And, IF you must do it within such a real scripting language, instead of just clicking together key pressings, is it reasonable to learn a proprietary language that will be defunct when their developers lose their interest? And that’s absolutely possible since the more elaborate such a language is, the more it is in your interest to learn some “real” script language instead, and the less it is given that this proprietary langue will be bought again and again by new scripters making their choice, hence the roaring probability of it being buried at one moment or another.
If you are interested in having a look at a typical macro language that tries to do “more” but in incredible ways, have a look at Quickeys for Windows (and its if structure) - and have a look at its dated version.
I stayed many years with a macro tool, for fear of having to invest a week of more into transcripting all my stuff into a script language - and then, it was more than just 40 hours, but including much new functionality nethertheless…
(Ok, one of the offerings of (the better) macro tools is that you can have built up your first menu within 30 minutes whilst in scripting languages, it will take you some hours to understand how to build it up with your proper means - help files ain’t that good around here…)
II
So, if you want some functionality, your best bet is going for one of the two free script languages out there, i.e. AHK and AI.
The Kant professor in this forum (up to 2010 or early 2011) swore by AHK, but he also swore by ConnectedText, and that should have me warned, since CT “does it all”, presumably, but is missing the most important feature of them all, a viable tree structure.
There are many “AHK vs. AI” posts in the web, but most of them are simply too much biased in order to be worthwile. People say AHK has horrible syntax but do not explain. Other people say AI has a forum where experienced, professional programmers agress “dumb” newbies. Then, people say in AHK it’s much easier to assign shortkeys. Finally, you get the info, “AHK hasn’t got arrays”, then others say, “that’s true, but latest version of AHK is from 2009 anyway, so the “current” version of AHK is AHK_L anyway, WITH arrays, so what?”
This is all true, or is it not?
Outright liars - or simplets - even pretend that since AHK is outsourced from AI, they have similar syntax - nothing could be wronger.
The AI forum isn’t that nice indeed, whilst the AHK forum is much more accessible in every respect; at the end of the day, you’ll get professional help in both.
With AHK, make sure you download AHK_L, and then make sure you only use the (good) offline help coming with it, don’t refer to the AHK online help anymore, at least concerning the alphabetical commands list, etc.
III
If you never did any programming, and never will do, AHK’s macro (vs. micro) syntax would be “acceptable” whilst in any other case it is weird, weird, weird. This is an conditions structure:
key assignment
some code
if abc
{
blabla = anything you need here
}
else if
{
blabla
}
else if, etc., etc., then:
else
{
bla
}
return
next key assingment
And no, there is no “endif” or “end if”, and similar for anything you could imagine. So much for the “macro” syntax.
IV
Now for the “micro” syntax in AHK. Many commands are in the form
something, sothis, andthat,,andsomeotherattributeorsuch,,,whatevermightbehere,etc,
and you must put strings into quotes, OR NOT, depending on the command in question, and you must put variables within p.c. signs, or not.
Other commands are in the form
something(sothis, andthat,,etc.etc.etc, see above),
and you must put strings into quotes, OR NOT, and variables into p.c. signs, or not,
and there are commands like send this, with/without quotes/p.c. signs, or msgbox, with/without quotes/p.c. signs, etc., etc. ad infinitum
Similar for assigning values to variables, there is not one way, but there are several ways, but these several ways of doing things are allowed here, not allowed there, whilst at another place yet, you MUST apply a certain way, but in which only this or that way of doing things is allowed…
V
Which is to say, in AHK, there is an inconsistency “AHK vs. other programming languages” you can come by since there IS consistency within AHK, at least (even this is theoretically wrong since there are different ways to structure, but at least you can leave out those “simplifications” - that are allowed here but not allowed there! - altogether and THEN have a consistent “macro” structure).
But on the “micro” level, on the sub-structure, command line level, there is NO consistency in AHK whatsoever, since opposite to the above, you can NOT adopt one single strategy (be it more fuss, but consistent in itself), but must adopt this way in this command, another way in another. This invariable means you’ll write down the needed commands, together with the ways you will have found out are working, on a sheet of paper, hoping in another situation, with some different attribute, it will not be totally different again from what you found out - and it means you will use the tiniest possible number of commands, for fear of horrible beginners’ problems with every new command you would find useful, and that means that your scripts will probably be of horrible-syntax-induced, “unnecessary” poverty - or you see AHK as another iq test, and probable spend lots of unnecessary times coding with it, whilst in a consistent scripting language, that is consistent with traditional programming languages, on the macro level, you could do rather fast work since you would not have to think, “this is AHK, so which way must i do it otherwise, because of that?”, and on the micro level, you would memorize the usual commands rather fast, and for any command new to you, you would have a basic perception how it will work in a consistent way with other such commands within the same language.
VI
This would make us choose AI. But then, perhaps, those key assinments in AHK are worth all the fuss? Well, they are not. In fact, for a “bloody” beginner, AHK’s key assinments are MUCH easier than anything anywhere else, so, indeed, this USP of AHK will charm you immediately. But rather quickly, you will realize that this way of doing grouped key assignments in AHK, depending on scope (by preceding ifthisthisparticularwindow commands) isn’t but a trap since what about commands belonging together, similar commands in different applications, different commands depending on global language variables, etc.? In any code, there is a two-dimensional representation only of your routines, not a three-dimensional one as is in your outliner (provided it offers clones). Thus, even in AHK with those application headings for key assinments, perhaps another key bindings structure, relying on (different! = a combination of!) global variables might be better indeed?! So, the normal key assignments don’t do it: There are very good at first sight, but at the end of the day, in AI you can do in as good a way as you’d do it in AHK - no advantage for either script language here.
VII
What about arrays, then? Yes, AI has got normal arrays, like any other normal programming language has: You assign and retrieve values as you ever did anwhere else, whilst in AHK, arrays are just another total nightmare. AHK (final “Chris” version, from 2009) has pseudo-arrays (!), sort of simili-grouped normal variables, spread in your memory, and for some 5 or 10 values, that might be it even it it’s the most ugly “programming” you will ever have done. AHL_L has got “real” arrays, they say, but in the web, I didn’t find more detailed info on that subject.
When you install AHK_L, you’ll install its help file with it, and there you’ll get your information, and yes, it’s another nightmare. Arrays can be ONE-dimensional only, and if you need more than one dimension - and most of the time you’ll do -, you can “insert” one array into another, or something: So, in a ten-rows array, you’d insert 10 other arrays, in order to get an array[10][2]? Don’t know, didn’t understand a mumbling word of what they say (and I have treated with multi-dimensional arrays many years of my life). (see below)
VIII
Thus, I simply had to renounce on doing a script for my outliner I so much had wanted to do, since I simply did not want to “learn” this weird thing of doing so-called “arrays” in AHK - j’en avais ras-le-bol, as we other French-speaking people say.
Let me explain: I have used a very expensive script language plus scriptable editors in order to run text processing scripts, will transfer my workflow to AI plus scriptable editors - should perhaps learned Perl instead to begin with… But for my “general scripting work”, i.e. for doing all these little things you’d normally do with a macro program, I’ve been using AHK for some time now - and of course, compared with my former macro tool, my possibilities are “endless”. But why not using AI for my “general purposes” also, thus avoiding all the AHK problems I’ve enumerated here?
Because of AHK’s text expanding facilities. There seems to be an additional sw / elaborate script that more or less “integrates” that power into AI scripts as well, but I never tried it - should have done so, I fear -, and so I don’t nothing about its ease of use (= which implies ease of doing changes, especially here with text expansions!!!), response times (= especially here with text expansions, again!!!) or anything else.
So, I simply adopted AHK for the relative ease of key assignments here, and of its incredible ease of doing text expansion with it, since this appeared to me the prevailing criterion for “general purposes” where indeed ease of constant, permanent, never-ending revision of all these little things here and there, and ease of use, and ease of revision, of text expansions, seemed to me more important than anything else.
As for the missing array[100][3] - not a “big thing”, then -, I’ll realize the whole script with AI, triggering it with AHK on the rare occasions I’ll be in need of it.
IX
So, what’ve you got here? As with any other kind of sw (e.g. editors! not speaking of outliners!) or product (I’m leaving out people here), there is no easy one-does-it-all solution here, and all I could do was detailing some aspects and the temporary decisions I inferred from them, for myself. This being said, whenever AI will get better-integrated text expansion, I’ll perhaps translate - script-driven as far as it’ll be reasonable! - my currently about 3,000 lines of AHK code to AI.
But the most important step was to do the transition from a macro tool to a script language, even if here and there, I reproach myself with having made the bad choice.