Author: Yonken
As far as I know, many of the users who need to write Autohotkey/autoit scripts to automate their operations are network administrators, others may be individual users, who generally have a considerable level of skill, and want to use scripts to accomplish certain repetitive tasks that previously required manual manipulation, But limitations on language conditions may be more difficult to understand in official help documents. For the convenience of the reader, I will start with the simplest, with each example giving the appropriate AHK and AU3 version code as much as possible. This article will be as far as possible in a more popular language description, but do not intend to explain the grammatical basis, so not necessarily suitable for beginners to read.
The AHK/AU3 version involved in the article:
AutoHotkey
1.0.44.08
AutoIt
3.1.1
First, about the script
1, what is a script?
This is a very "popular" term, and in general, scripts (script) refer to text files in a particular format written according to some grammatical rules. Maybe you've heard a lot of scripts: VBScript, JScript, PHP, ASP, JSP, CGI, CS scripts, and even game plug-in scripts.
These script files are executable files that perform the appropriate actions.
AHK script file name extension: *.ahk
AU3 script file name extension: *.AU3
2. What are the differences between scripts and programs?
Strictly speaking, the so-called "program" refers to a variety of programming languages (such as C/c++/c#/delphi) written, compiled by the compiler after the binary files, is generally machine code, can be implemented by the system. Scripts are just plain text files that contain a variety of well-defined commands, much like batch files. So, we come to a simple conclusion, that is, users generally can not get the "program" source code, we can only disassemble it back to the assembly language code (or other), of course, some "programs" can get the source code (such as Java), the script is the user can directly view the code files, AHK/AU3, however, provides a way to "transform" the script file into an EXE file.
3, how does the script run?
The script is an "explanatory" language, and its operation relies on an "interpreter" that "translates and interprets" each command (or code) of the script, and then performs the appropriate action. If not strictly defined, both HTML and Java can be interpreted as interpretative languages. AHK/AU3 's main program (AutoHotkey.exe and AutoIt3.exe) is their "interpreter", which mentions that scripts can be "transformed" into EXE executables that run independently of the interpreter, and we can "restore" them using the appropriate tools. into a script file, which we can fully understand: The script code is "compressed" into this EXE file, the interpreter is inside, in the run EXE is actually first "unzip" the script code and then run the interpreter and explain the script.
4. How do I create a script?
Use the Resource Manager's right-click menu to create the appropriate script file, or you can change the extension by creating a new text file.
5. A little introduction to grammar rules?
(A) for AHK, each built-in function is provided in the form of "command":
Command, param1, param2,...
And AU3 is provided in the form of "function":
Function (param1, param2, ...)
Parameters that are enclosed in a command or function by the symbol "[" and "]" are optional arguments that can be omitted (without specifying a numeric value) when these commands or functions are used.
If a parameter contains spaces, it is best to surround the parameter with double quotes.
B The interpreter interprets each line of the script from top to bottom (from the first line to the last line) unless you encounter statements, functions, hotkeys, or other words such as "return", "Goto", "GoSub", "Exit", or other conditions that enable the script to "jump" to an identifier.
C keywords and identifiers (including variable names, command names, function names, and so on) are case-insensitive.
Current 1/5 page
12345 Next read the full text