AutoHotkey Versus AutoItA Comparison and Review of the Free Windows Scripting Languagesby Jack DunningWhen people begin investigating AutoHotkey, they soon discover that its roots lie in the older Windows scripting language AutoIt. Both programs have active support and serve very similar purposes by adding power to your Windows computer. The question is "Which language is right for you?" Before answering that question the two languages must be compared and contrasted. A Google search will uncover many discussions comparing the two Windows scripting tools, but most of the conclusions come down to people liking what they know best. In this chapter I endeavor to offer enough factual information about both free programs for you to make an informed decision—although the only way to know for sure which is best for you is by testing both..Full Disclosure: While I attempt to put aside my personal bias (I've written ten AutoHotkey books) and give a fact-based appraisal grounded upon my research and knowledge of programming languages, I do not have the same in depth knowledge of AutoIt that I do of AutoHotkey. Fortunately, there is a good deal of data for review from people who have used both languages. First, since both AutoHotkey and AutoIt are free to use, there is no reason not to test or use both. I'm a great believer in using the right tool for the job—especially when the tools are free. If you are comfortable with writing scripts, then you may be served well by playing with each language for particular purposes. There may be applications where one is more suitable than the other. The only cost is the time it takes to do it. It's important to note that the current versions of the AutoHotkey and AutoIt languages are not interchangeable. Each has its own particular syntax (set of commands and functions) which, while they are capable of accomplishing the same thing, are written in a totally different manner. To make an informed decision you will want to see those differences. A couple of simple examples are provided below. The Names AutoHotkey and AutoItThe name of each scripting language gives us insight into the differences between the two. While you can do almost anything in AutoHotkey that you can in AutoIt (and vice versa), there are some noticeable differences. The underlying meaning of the terms AutoIt and AutoHotkey express the original impetus for each program. While both are used for Windows program automation, that is the primary thrust of AutoIt—thus the name. As suggested by the name AutoHotkey, hotkey creation and hotstring replacement through keyboard action is integral to the program. While AutoHotkey has implemented simple ways to create hotkeys and hotstrings, the AutoIt community has never consider those features high priority—although there is a specific function for creating hotkeys in AutoIt—HotKeySet(). It seems that the split occurred after programmer "Chris Mallett's proposal to integrate hotkey support into AutoIt v2" received little response from the AutoIt community causing Mallett to start writing his own version of the then open source AutoIt—calling it AutoHotkey. The name AutoHotkey demonstrates the primary functional difference between the two scripting languages. AutoHotkey offers simple direct support for one-line assignment of hotkeys and hotstrings while the current version of AutoIt requires the use of functions to implement the same or similar hotkey and hotstring features. (See the comparisons below.) This has caused the two language to be viewed very differently. You might say that AutoIt is for Windows automation and AutoHotkey for easy implementation of Windows hotkeys and hotstrings plus Windows automation. (This is not a completely fair comparison since Windows automation, app development, and hotkey/hotstring implementation can be done with either scripting language. They are just done in a different way.) The result is that many AutoHotkey users who have switched have been extremely pleased with the results after converting most of their scripts to AutoIt, but, even then, they tend to continue using AutoHotkey for their hotkey/hotstring implementations—especially with long list of hotstrings such as the AutoCorrect scripts. Understand that most of these individuals who made the jump to AutoIt from AutoHotkey are more experienced with script writing and programming. Update December 17, 2015: After completing a series of blogs on AutoHotkey Hotstrings, I've come to realize that there are many people who might want to use AutoHotkey just for the easy built-in Hotstring structure. If you're a writer, student, or anyone else who does a lot of word processing, then you'll be amazed at the AutoCorrect and text expansion/replacement capabilities of AutoHotkey. There are many cool text tricks which you can implement with Hotstrings. This applies equally to the simple built-in basic Hotkey structure in AutoHotkey.For beginning script writers, the syntax for hotkeys and hotstrings (text expansion) is much simpler in AutoHotkey (a couple of colons ::). This attracts novice users since their first scripts often consists of this type of easy coding. As these beginners become more daring, they naturally venture into the other slightly more complex commands found in AutoHotkey. The function oriented language of AutoIt may be intimidating for the newbie while it might be more natural for the experienced programmer. The commands in the early versions of AutoIt looked very much like those in the current release of AutoHotkey. After the split between the two languages, AutoIt moved in a new direction (version 3) using more BASIC-like functions while AutoHotkey continued with the original command structure used in the early versions of AutoIt. I don't know that there is a clear advantage of one language structure over the other, but each certainly has its own separate learning curve. AutoHotkey Versus AutoIt for Hotkeys and HotstringsThe following is an example of what's required to set up a hotkey in AutoHotkey: Insert::Run, %A_MyDocuments%It's one line of code that turns the INSERT (Insert) into a hotkey which opens your Windows Documents folder. The percent signs (%) surrounding the built-in variable A_MyDocuments evaluates the path to the Documents folder. In AutoIt it takes few more lines: HotKeySet("{Ins}", "openDocs")The first line uses the AutoIt function HotKeySet() to assign the INSERT key (Ins) to run the user defined function openDocs(). The openDocs() function uses the Run() function to open the Windows Explorer.exe program at the user's documents folder—designated by the macro (built-in variable) @MyDocumentsDir. The ampersand (&) appears to be the symbol for concatenation (combining strings). As can be seen, there are a few more lines needed in AutoIt. This is comfortable for experienced script writers, but could be confusing for the average Windows user. This next example is a text expansion (or hotstring) for the phrase "by the way" in AutoHotkey: ::btw::by the wayHotstrings are assigned by placing double colons (::) at the beginning of the line followed by the hotstring and another set of double colons (::btw::). The replacement text (by the way) follows the second set of double colons. Once the script is loaded, anytime "btw" is typed followed by a space or punctuation, it is automatically replaced with "by the way." I couldn't find a built-in hotstring function in AutoIt, but I did locate this example which includes a special AutoIt script (HotString.au3) to create the function HotStringSet(): #include <HotString.au3>To replicate the AutoHotkey example would require the use of the AutoIt Send() function in place of the MsgBox() function. If you need text expansion, then it looks like AutoHotkey may be your program of choice. This is not a minor point since the same simple hotstring technique found in AutoHotkey (in a slightly different format) can be used to run a set of commands in the same manner as a hotkey subroutine. Both languages are capable of much more involved programming and Windows app building which have nothing to do with either automation or hotkeys/hotstrings. AutoHotkey syntax uses primarily text commands whereas AutoIt uses functions. For example, to add a button to a Graphic User Interface (GUI) window AutoHotkey uses the following command: Gui, Add, Button [, Options, Text]To create a Gui button in AutoIt the following function is used: GUICtrlCreateButton( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )This is not a major difference for experienced programmers, but it you've grown accustomed to doing it one way, switching to another method requires developing a different mindset. While there is no particular advantage to the AutoHotkey command structure, it may look simpler to the novice. The Confusing Side of AutoHotkeyIn many ways the current AutoIt version is a much cleaner language than AutoHotkey. It has not fallen victim to the confusion caused by maintaining backward compatibility with older scripts. Since virtually any older AutoHotkey script will run with the current 1.1 version (AutoHotkey_L) of AutoHotkey, there are numerous redundant commands and methods for getting the same thing done. This is a source of confusion for AutoHotkey users because, although there is more than one way to get something done, each requires a different implementation. The classic example is the use of both the equals sign (=) and a colon plus the equals sign (:=) to assign a value to a variable: MyString = This is a literal stringand MyString := "This is a literal string."are identical sets of expressions. But if you use the wrong one in the wrong place with the wrong format, your script won't run properly. There are a number of other examples of this type of duplication caused by legacy AutoHotkey commands included for backward compatibility. Often the different variations may be used in the same script. There is an attempt underway to fix the problem and clean up the code with version 2.0 of AutoHotkey. (Version 2.0 is still in the alpha stage of development and not recommended for newbies.) It is designed to eliminate the excess baggage. However, that would mean that many of the scripts available today would no longer run properly with the new version of AutoHotkey. It is difficult to know how widely this new, cleaner version would be accepted. The changes which would be required in older scripts are not well documented and many people will not relish the extra work. As far as I know, AutoIt does not have a similar issue. Interest in AutoHotkey Versus AutoItBased upon links found on Google Trends, interest in AutoHotkey appears to have caught up with AutoIt. (See Figure 1.) This is a momentum which is not likely to reverse. Figure 1. Interest in AutoHotkey in the United States has slowly caught up with AutoIt. The trend favors AutoHotkey. The primary reason for the growth of AutoHotkey is its initial simplicity. It's easy for the beginning script writer to get a result with just one line of code in a text file (a hotkey assignment or text string expansion). This is what got me started. Over time, and with a little curiosity, newbies start experimenting with other simple commands and scripts. Eventually, they are hooked and become part of the AutoHotkey community ready to help others. Since many of the users don't consider themselves to be programmers, the AutoHotkey community works to help each other and is welcoming to beginning users. There are numerous online tutorials and people don't usually face impatiences when they ask newbie questions on a forum. (My experience on the AutoHotkey forums is that at any given time there are usually a number of people online willing and able to answer novice questions.) This makes it easier for people who have never before written a program. Using AutoIt is a bit more daunting for the newbie script writer. If you're not already a programmer, the concept of using functions can be a little difficult to wrap your brain around. As far as I can see, there is no easy entry point in AutoIt for the complete novice. AutoIt seems to be used more by computing professionals and possibly to a greater degree within corporations. (I have no data to back up this statement, but it was a feeling expressed by AutoIt users.) If I had started with AutoIt first, then, who knows(?), I could be writing AutoIt books. However, I'm not sure the AutoIt users are as likely to need the help. As it is I'm happy with AutoHotkey—even with all of its quirks and idiosyncrasies. It's good stuff. Some people suggest that AutoHotkey is not as extensive as AutoIt. I would be forced to differ. While there may be some minor technical advantages to AutoIt, I haven't seen much bragged about in AutoIt (arrays, object oriented coding, etc.) which isn't now available in the current version of AutoHotkey 1.1. As far as I can see, both have a great deal of capability for building Windows apps. If more is needed, then possibly the programmers should consider using a programming language such as C++ or Java. If you're an experienced programmer and the simple hotkey and hotstring assignment found in AutoHotkey is not a requirement in your work, then I would likely recommend AutoIt as your Windows scripting language. If you're a beginner, then AutoHotkey may be just what you need. If you're somewhere in between, then it's a coin toss. Or, maybe you should use both—depending upon what you want to do. Get this AutoHotkey
overview
e-book Free, AutoHotkey
Tricks You Ought to Do with Windows! * * *
The
second edition with more chapters and an index to the AutoHotkey
commands found in the book is available in e-book format from Amazon
(and other formats—EPUB and PDF— at the ComputorEdgeBooks Web site
linked below). Jack's A Beginner's Guide to AutoHotkey, Absolutely
the Best Free Windows Utility Software Ever!: Create Power Tools for
Windows XP, Windows Vista, Windows 7 and Windows 8 (preferred,
EPUB format for iPad, Android, and computers; MOBI for Amazon Kindle;
and PDF for printing) offers a gentle approach to learning AutoHotkey.
(Also available from Amazon for the Kindle and Kindle
software on other devices.)Building Power Tools for Windows XP, Windows Vista, Windows 7 and Windows 8, AutoHotkey is the most powerful, flexible, free Windows utility software available. Anyone can instantly add more of the functions that they want in all of their Windows programs, whether installed on their computer or while working on the Web. AutoHotkey has a universality not found in any other Windows utility—free or paid. Based upon the series of articles in ComputorEdge, Jack takes you through his learning experience as he explores writing simple AutoHotkey scripts for adding repetitive text in any program or on the Web, running programs with special hotkeys or gadgets, manipulating the size and screen location of windows, making any window always-on-top, copying and moving files, and much more. Each chapter builds on the previous chapters. For an EPUB (iPad, NOOK, etc.) version of A Beginner's Guide to AutoHotkey click here! For a PDF version for printing on letter size paper for inclusion in a standard notebook of A Beginner's Guide to AutoHotkey click here! * * *
Jack's second AutoHotkey book, Digging Deeper Into AutoHotkey (preferred, EPUB format for iPad, Android, and computers; MOBI for Amazon Kindle; and PDF for printing) is comprised of updated, reorganized and indexed columns from ComputorEdge is now available. Since the columns were not all written in a linear fashion, the book has been reorganized and broken up into parts by topic. The book is not for the complete beginner since it builds on the information in A Beginner's Guide to AutoHotkey. However, if a person is reasonably computer literate, they could go directly to this book for ideas and techniques without the first book. (Also available from Amazon for the Kindle and Kindle software on other devices.) For an EPUB (iPad, NOOK, etc.) version of Digging Deeper into AutoHotkey click here! For a PDF version for printing on letter size paper for inclusion in a standard notebook of Digging Deeper into AutoHotkey click here! * * *
Jack's third AutoHotkey book AutoHotkey Applications (preferred, EPUB format for iPad, Android, and computers; MOBI for Amazon Kindle; and PDF for printing) is an intermediate level book of ideas and applications based primarily on the AutoHotkey GUI command. The book emphasizes practical applications. The book is not for the complete beginner since it builds on the information in the other two books. However, if a person is reasonably computer literate, they could go directly to this book for ideas and techniques without the other books. There is an extensive index to the ideas and techniques covered in the back of the book. (Also available from Amazon for the Kindle and Kindle software on other devices.) For an EPUB (iPad, NOOK, etc.) version of AutoHotkey Applications click here! For a PDF version for printing on letter size paper for inclusion in a standard notebook of AutoHotkey Applications click here! * * *
This Beginner's Guide to Using Regular Expressions in AutoHotkey is not a beginning level AutoHotkey book, but an introduction to using Regular Expressions in AutoHotkey (or most other programming languages). To get the most from this book you should already have a basic understanding of AutoHotkey (or another programming language). Regular Expressions (RegEx) are a powerful way to search and alter documents without the limitations of most of the standard matching functions. At first, the use of RegEx can be confusing and mysterious. This book clears up the confusion with easy analogies for understanding how RegEx works and examples of practical AutoHotkey applications. "Regular Expressions in AutoHotkey" will take you to the next level in AutoHotkey scripting while adding more flexibility and power to your Windows apps. (This book is also available at Amazon.com) For additional
AutoHotkey books in all formats, visit ComputorEdge E-Books.
|