Autoit launch the program with parameters. An employee on a leash: Review of programs for automating routine operations

OS Windows has gained popularity primarily due to its convenient and clear interface. But if regular user From this only benefited, but for the admin, push-button control has many inconveniences. Of course, some problems can be solved by console commands and scripts, but not all. And here they come to the rescue special means automation.

AutoIt

One of the most popular automation tools among administrators is AutoIt (autoitscript.com/autoit3), which simulates keystrokes, mouse clicks and other similar actions that a user usually performs when working in GUI applications.

Using AutoIt, all of these movements can be programmed using a BASIC-like language. The program can manage processes, access the Windows API and DLL, the registry, clipboard, files (reading, changing, deleting), creating GUI, messages, data entry forms, working with databases (MySQL and SQLite), reading HTML code, download files, send e-mails and much more. In general, it all depends solely on the desire to tinker with the settings. It is gratifying that AutoIt does not require programming skills from the administrator. In scripts, you can easily access window controls with just a couple of lines of code. However, it should be remembered that AutoIt works without problems with standard Windows windows. If the authors took care of the uniqueness of the interface, you will have to work a little while setting up AutoIt to find the necessary parameters.

Supports Windows from 95 to 2k8, including working in 64-bit versions of the system, and is “friendly” with Vista UAC. It’s convenient that scripts can be compiled into an exe and then executed on another machine. None additional applications and no libraries are required.

AutoIt is distributed under a freeware license, allowing its use without restrictions, including for commercial purposes. Installation is standard, there are no additional requirements. The current version is 3, which is syntax incompatible with the previous version 2. The program comes with the SciTE4AutoIt3 script editor, the AU3Check.exe syntax checking utility, ready-made examples, the Aut2Exe (and reverse Exe2Aut) compiler, and help. During installation, the *.au3 extension will be mapped to the AutoIt interpreter.

The scripting language used in AutoIt is one of its strengths. It is both powerful and simple. For example, to run the program, just write:

That's it, no more action. AutoIt is a great way to automate the installation process for applications that don't support answer files. To catch windows, the WinWaitActive function is usually used to enter parameters, which interrupts script execution until the window is activated. The function parameters should include the window title and optional additional text. The latter allows you to distinguish different windows of the same program from each other. For example, the AutoIt installer windows contain the same title - AutoIt v3.3.6.1.5, that is, if you use:

WinWaitActive("AutoIt v3.3.6.1.5")

This design will match all installer steps. Therefore, it is better to clarify by entering additional text that is displayed in the window, for example:

WinWaitActive("AutoIt v3.3.6.1.5", "License Agreement")

This will definitely take us to the license agreement window. All that remains is to send him confirmation: Send("!y")

As you can see, everything is simple. Along with the programs, the AutoIt Window Info Tool (AU3Info.exe) utility is also installed, which will help you get all the information on the window title, text (displayed and hidden), status bar, location, color, and so on. We just run it and place a cross on the window, after which we read all the values ​​in the Window Info Tool. With its help, it is much easier to collect the necessary information from the experimental program window. Help in AutoIt is very detailed, it has all the details on using the language. In the documentation on the project website you will find a link to a translated version of the help. Plus, numerous specialized forums usually have a separate thread. There shouldn’t be any problems in learning AutoIt; in one evening you can learn how to write simple scripts; complex solutions will naturally require a lot of time.

Xstarter

Another one popular program to automate routine system administrator tasks. The developer is our compatriot, Alexey Gilev (xstarter.com/rus), accordingly, xStarter has a localized interface, and most importantly, the program is distributed free of charge for Russian-speaking users.

After installation, xStarter can be launched manually, automatically when the user logs in, or started as a Windows service. The last option allows you to run the job exactly specified time, regardless of the user’s registration in the system and other factors, as long as the computer is turned on. It offers periodic execution of tasks, a composite schedule, setting skips and actions for missed tasks, and triggering by event. In general, there are more than enough options. Using xStarter, you can expand the list of hotkeys or redefine their values ​​globally or locally. For example, you can easily make a task run when you press a key combination , but only if Firefox is running.

The running program is placed in the tray; by clicking on the icon, we call up the task editor. In the Sections/Tasks window we will find two dozen examples, as they say, for all cases. Enabled tasks are marked with a green icon.

We choose the one that is closest in meaning (or create new task), copy using context menu and edit it to suit your needs. Each task is configured in four tabs. So, in the “Schedule and Information” tab we indicate the name of the task, the time or event at which it will be launched, a key combination and an optionally active program window, when it appears, the task should be executed. The macros themselves are written in the “Actions” tab. Click “New Action” - the settings window appears. On the left side we find presets, divided into several groups, then we specify the parameters on the right side. The remaining task tabs allow you to configure variables, set priority, run in separate process, logging. Everything is very simple and clear.

To activate blocked functions, you must additionally install the xStartHooks module. In this case, xStarter will behave like a typical Trojan or malicious software - it will begin to intercept system calls, “press” keys and send messages, which antiviruses and fireware may not like. But with some antiviruses (for example, NOD32) this can be easily solved; just add xStarter to the exceptions.

For convenience, macros can be compiled into an exe file; under certain settings, all necessary libraries can be automatically added here. Then we distribute such files to other systems and execute them.

It remains to add that all Windows operating systems from NT4 to 2k8/7 are supported.

On the project forum you can find examples of some popular tasks, including uploading files, sending SMS and e-mail, backup and data synchronization.
A special version of Starter Job Scheduler for Firebird/Interbase is also available on the site; it is designed to execute SQL scripts, backup and restore data in these DBMSs. Another unique opportunity - remote control launching tasks, as well as viewing the log using special application xStarter Web Pilot.

Automate

Probably the most famous commercial program for automating tasks is AutoMate, developed by Network Automation, Inc (networkautomation.com). Its main feature is the creation of tasks using a convenient GUI, without the need to write code. The entire process is simplified through the use of wizards and a special task editor, Task Builder. The program contains a large number of ready-made action templates and reactions to them, which further simplifies the process of creating a chain of actions. The current version of AutoMate 7 at the time of writing supports more than 230 predefined actions that allow you to schedule tasks, work with files and databases, transfer data via FTP/SFTP, encrypt using PGP, monitor systems, access WMI and much more.

AutoMate is available in four editions, all tailored to specific uses: AutoMate Professional and Premium, AutoMateBPAServer 7 Standard and Enterprise. The simplest - AutoMate Professional - provides a convenient interface for creating tasks on local system. The most advanced - Enterprise - provides the ability to easily manage accounts and roles, work in AD, provides centralized management of several machines, SNMP support, a telnet and terminal emulator.
All Win OS from XP SP2 to 2k8/7 are supported. For installation you will need Microsoft platform.NET Framework version 3.0.

The actual management is carried out using two consoles - Task Builder and Task Administrator. Tasks are created in Task Builder. This process is quite simple: in the panel on the left, from the 29 available groups, select required action and move it with the mouse to the middle field. A wizard appears to help you refine your settings. For example, let's create an action that allows you to get data on hard section disk. Go to the menu System –> Get Volume Information, a wizard of the same name appears, consisting of four tabs.

We need to go through and select the parameters in each of them sequentially. In General we indicate the disk partition and the parameters that we want to receive: type, label, file system, place. Alternatively, you can immediately select All volumes and then, by clicking the icon next to the field, set the verification condition. The program provides a number of built-in variables, functions and triggers that can be used in this field. You can also create your own condition. In other tabs, a description of the task and action in case of errors are specified.
After you create a task, it appears in the list in the middle, where you can edit it, move it, disable it, and so on. Next, select and enter other Actions in the same way. For debugging, you can add breakpoints to the job (Breakpoint, ).

Task Administrator is designed to manage all tasks, both on a local and remote system. Having selected any task in it, we can view its properties, activate it, or create a new task. In the properties of the task, triggers, priority, protection, Account, on behalf of which it will be executed. There are many settings, they are very diverse. Tasks are saved in files with the *.aml extension.

AutoHotkey

AutoHotkey (autohotkey.com) is a fork of AutoIt v2. Its author, Chris Mallett, proposed adding hotkey support to AutoIt, but the idea did not find a response, and as a result, the Initial release was released in November 2003. Unlike its parent product, AutoHotkey is available under the GNU GPL license.

The language syntax is based on AutoIt v2, some ideas are taken from v3. With its help, you can easily automate repetitive tasks: launching a program, sending mail, editing the registry. It supports working with files, simulating mouse button presses, and it is possible to create a GUI. The program can monitor system events and perform actions when they occur.

But the trick of AutoHotkey is the management of hot keys. For example, to launch a calculator with the combination , we write just one line:

The hash mark "#" corresponds to a key . The documentation is very detailed (translation is available at www.script-coding.info/AutoHotkeyTranslation.html), it reflects all the features of the language. In addition to the interpreter itself, the project offers a utility for creating a GUI - SmartGUI Creator and the SciTE4AutoHotkey editor, which has highlighting and code completion.

Scripts (*.ahk extension) can be compiled into an exe file and executed on any computer.

Automatically install Firefox using AutoIt

AutoItSetOption("WinTitleMatchMode", 2)
AutoItSetOption("WinDetectHiddenText", 1)
WinMinimizeAll()
Sleep (1000)
Run("FirefoxSetup3.6.6.exe")
WinWait("Install Mozilla Firefox")
Send("(ENTER)")
WinWait("Mozilla Firefox Installation", "Installation Type")
Send("(ENTER)")
WinWait("Install Mozilla Firefox", "Summary")
Send("(ENTER)")
WinWait("Install Mozilla Firefox", "Shutdown
installation wizard")
Send("(ENTER)")
Exit

AUTOMATION ANYWHERE

The development of the Californian company Tethys Solutions, LLC () has already earned recognition from administrators and received awards from various media publications. With Automation Anywhere, you can easily automate any repetitive task, simple or complex, without the need for programming.

I’ll say right away that the product is very serious and has a huge number of possibilities. The program can work with files, send mail, run tasks according to a plan or when a trigger is triggered, use VBS scripts and JavaScript and much more. The technology, called “SMART Automation Technology,” eliminates the need for an administrator to also be a programmer. Recording can be done in automatic mode, when the computer records all user actions. In the future, such a task, immediately or after editing, can be “scrolled” on other systems, watching how the mouse itself runs across the screen and presses buttons. The program offers two recorders: Object Recorder for desktop applications and Web Recorder for recording sequences of actions in a web browser.

Moreover, Web Recorder latest version The program supports all the main technologies used in the web: Java, JavaScript, AJAX, Flash, frames. The process is quite simple: launch Automation Anywhere, select the recorder, and the program begins recording all user actions. To stop, press the combination or click on the “Stop” icon in the floating window at the bottom of the screen. At the end of the process, the program will offer to save the recording to a file (extension *.atmn). Editing, as well as manual creation of a task, is done using the Task Editor.

The developers have already included several task templates in the program that can be used as examples. Editing a recorded task also does not require knowledge of code. By clicking the Edit button, we will see the entire sequence of actions performed on the screen (mouse movements, keystrokes).

The left editor window shows predefined commands, divided into categories, that can be added to the task. It has everything: working with files and directories, backup, Excel tables, connecting to the Internet, sending e-mail, capturing desktop images, starting/stopping services. Select the desired task and simply drag it into the right window. A properties editing window immediately opens, in which we fill in the proposed parameters (they are specific for each item). The editor supports additional scripts, working with variables, debugging and much more.

The created task can be exported to an executable file and distributed to other systems.

The task can start by time or when a trigger is fired, this behavior is configured in Trigger Manager, here you can choose: launching a window with a certain text, appearance of a file in the directory, resource load (CPU, memory, free space), start/stop of a process or service, receiving a specific e-mail. The developers did not forget about security - Automation Anywhere allows you to protect the script with a password and encrypt it.

In general, everything you need is in the program, the only thing missing is localization. Automation Anywhere supports all versions of Windows: from XP to 2k8/7.

Conclusion

In fact, there are much more programs for automating routine tasks. Paid versions are distinguished by greater convenience and a friendly interface, the ability to work in a network environment. Although, depending on your preparation and desire to tinker with the settings, you can get by with free programs like xStarter, AutoIt or AutoHotkey.

Standard Windows Task Scheduler

Microsoft finally realized the need for a proper scheduler, and, starting with Vista, the system received an improved Task Scheduler (Administration.. Task Scheduler, or taskschd.msc) - significantly redesigned compared to previous versions. Its interface allows you to connect to another computer for configuration, create (simple and advanced versions) or import a task. Thus, the main elements of the task were Triggers, Actions, Conditions and Settings. The trigger determines when and upon the occurrence of what event to run the task: by time, when the computer is turned on, when you log in, or when an event appears in the log. In the latter case, you must specify the log where the event will be tracked, the source and event code.

Conditions and parameters clarify the essence of the task, and the action determines what can actually be done (launch a program, send a message). The ability to delay starting a task allows you to delay the start in situations where its immediate start is unacceptable (for example, high system load). Conditions specify other options for executing a task, for example, while the computer is idle.



1. What is AutoIt3 for?

AutoIt is designed for general automation tasks. To achieve this goal, a standardized BASIC-like programming language was created. This means that if you are already familiar with any scripting programming languages, then you will most likely learn AutoIt v3 with ease.

2. Is AutoIt difficult to learn?

It is very easy to learn AutoIt3, look at the example of calling commands

9. Why, when I try to display the value of a variable using the "Variable value: $variable" construct, do I not get the expected result?

If you have a variable named $msg and you want to output it to MsgBox , then the following will NOT work:

12. How can I terminate a script when I press a hotkey?

If you want to terminate a script when a specific key combination is pressed, use the HotKeySet function, which runs a user-specified function when the specified key combination is pressed. This custom function should contain keyword Exit.

Below is the code that terminates the script when the key combination CTRL+ALT+x is pressed

13. How can I use my own icon for a compiled script?

You need to run the script compiler program (and not just select “Compile” when clicking right click mouse on the script file). This help page describes how the compiler works in more detail. Also use AutoIt3Wrapper to specify the icon in the script itself using directives.

14. How can I prevent a second copy of my script from running?

Use the _Singleton() function. See the User Defined Functions (UDF) help topic for more detailed information on how this function works and how to use it.

15. What are the technical limitations of AutoIt3?

Below you will find the current technical limitations imposed on AutoIt. Keep in mind that some limits are purely theoretical and you will likely reach performance or memory limits before the limit is triggered. Also see the section " "

Meaning Description
2147483647 Maximum length of a string variable. Considering the 2 GB limit per process and the characters in memory in Unicode, this significantly reduces the specified value
not limited Maximum number of GUI windows
5100 Maximum level nesting of recursive function calls
not limited Maximum number of user functions
not limited Maximum number of variables used in the script

Number range ate floating point with precision up to 15 decimal places

Integer range: 64-bit signed integer type

0x7FFFFFFFF

Range hexadecimal numbers: 32-bit signed integer type
64 Maximum number of dimensions in the array
16 million Total number of elements in the array

16. Why is there an image missing from the help file examples?

This should have been an “Open” button that opens the help examples in the editor window. This kind of error occurs when the hhctrl.ocx library is incorrectly registered in the system or this file is corrupted.
Try registering by running the command "regsvr32 hhctrl.ocx" (Run dialog via Win+R) or check the file's serviceability.


This article appeared on the site due to the popularity of AutoIt among forum visitors Automatic Installation Windows. The article consists of two parts. The first contains an introduction to AutoIt, taken entirely from the Russian help for AutoIt, which was very competently translated from English by Valery Ivanov. Unfortunately, it was not possible to find the author’s contact information, but I would like to believe that he does not object to the publication of his works. I highly recommend downloading the help and reviewing lessons, from which you will immediately learn how easy it is to automate application installations using AutoIt. The second part of the article is a list of frequently asked questions at the Oszone conference about working with AutoIt. The answers are, of course, attached. "Oszone AutoIt FAQ" has been prepared for you.

Introduction to AutoIt

AutoIt v3 is a BASIC-like scripting language. Its main purpose is to automate work with Windows GUI (MS Windows graphical user interface). To accomplish this complex task, a combination of proven techniques is provided, including simulating keyboard keystrokes, mouse pointer movements, and window and visual element manipulation. Experience has shown that these "drive belts" are very effective in producing workable solutions in situations where others standard means(for example, VBScript and SendKeys) are powerless.

AutoIt was intended to be a means of “replicating configurations” of a PC. But since the creation of the third version, its capabilities can be used to implement the “kitchen” of automation - writing scripts for solving various problems, including for system administration.

AutoIt can:

  • Simulate pressing keyboard combinations (most keyboard layouts are supported)
  • Simulate mouse pointer movements and button clicks
  • Move, resize and control window display options
  • Directly interact with the “controls” of the window (get/change the caption, move, disable, etc. actions)
  • Work with the clipboard to transfer its text content
  • Read, change and create registry keys and values

The new version of AutoIt3 recognizes common constructs and has a standard syntax reminiscent of VBScript and BASIC, and supports processing complex expressions, executing custom functions, and performing cyclic and conditional calculations. In addition, AutoIt3 is designed for everything that veteran screenwriters have been using for a long time.

As before, AutoIt has a small interpreter size (~100KB), which is independent and does not refer to other than system .dll libraries. He deliberately does not make independent or hidden entries in the register, except for those that are mandatory and part of the process. complete installation. Scripts can be compiled into independent executables using the supplied script compiler - Aut2Exe.

Along with the interpreter, the ActiveX and DLL version of AutoIt are upgraded, called AutoItX3. This library is a combined composite (COM and a standard DLL library in one module). AutoItX3 allows you to add unique AutoIt features to applications you write in other programming languages!

And finally, most significant is the fact that AutoIt remains free. However, if you are able to support this project with your time, money or other efforts, then all types of donations are accepted on the AutoIt home page.

Oszone AutoIt FAQ

Read the manual for AutoIt - a lot will become clearer :) What is stated below is something like a brief reference and a part-time FAQ.

Launching applications

  1. Normal launch
    Run("C:\Program Files\RivaTuner\RivaTuner.exe")
    ;or like this:
    FileChangeDir("C:\Program Files\RivaTuner\")
    Run("RivaTuner.exe")
    To universalize scripts, use macros, for example, instead of " C:\Program Files"It's much more practical to use a macro @ProgramFilesDir. Then the application launch command will look like this:
    Run(@ProgramFilesDir & "\RivaTuner\RivaTuner.exe")

    For a complete list of macros, see the manual section " Macro Reference".

  2. With completion waiting (convenient for quiet installation applications)
    RunWait("RivaTuner20RC158.exe /s")
    Please note that the first argument to the functions Run And RunWait is the FULL path to the executable file. You can write one name only in two cases - if the script is located in the same directory or after first changing the working directory with pom. functions FileChangeDir.

System Variables

  1. In principle, macros duplicate most system variables, but not all. You can get directly to their values ​​using the help. functions EnvGet, For example:
  2. Adding a path to a variable Path: ;for example, add the path to 7-Zip in Path$addtopath="%ProgramFiles%\7-Zip" $smcur="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet" & StringFormat("%03s",RegRead("HKEY_LOCAL_MACHINE\SYSTEM\Select","Current")) & "\Control\ Session Manager\Environment" $syscurpath=RegRead($smcur,"Path")
Influenced by: Influenced: Website:

AutoIt- freely distributed language For automation performing tasks in Microsoft Windows. In earlier versions, the program was primarily used for creating automation scripts (sometimes called macros) for programs Microsoft Windows. Such scripts useful for performing frequently repeated tasks, such as installing identical sets of programs on a large number of computers. Later versions of AutoIt improved the language design and increased overall functionality, bringing AutoIt closer to general-purpose languages.

With the release of AutoIt 3, the language syntax was restructured and moved closer to the family BASIC. The script can be compiled independent of what is installed on the system interpreter executable file.

AutoIt uses simulation of keystrokes, mouse movements and manipulation of windows and controls. This allows you to automate tasks Windows user in a way that is impossible or difficult in other programming languages. In addition, this language is compact, self-contained and works for everyone. Windows versions"straight out of the box", without external .dll libraries and registry entries, which allows you to safely use it on servers.

Language features include:

  • Compatible with Windows 2000/XP/2003/Vista/2008/Windows 7/2008 R2
  • Version for 64-bit systems.
  • Support for User Account Control (UAC) in Windows Vista.
  • Unicode support starting from version 3.2.4.0.
  • Run console applications and access standard input/output streams.
  • Running programs as another user (RunAs functions).
  • Compiling the script to EXE file using Aut2Exe.
  • Including files in the compiled file that can be extracted at startup.
  • Compression and protection executable file from decompilation using a packer UPX
  • Creation graphical interfaces GUI, information messages, information entry forms.
  • Calling functions from 32-bit dynamic libraries and Windows functions API.
  • Work with Windows registry, clipboard, files (reading, changing, copying, deleting).
  • Working with objects COM(component object modeling).
  • Interception and emulation keystrokes and mouse clicks.
  • Working with windows (especially standard ones): moving, hiding, showing, resizing, activating, closing, etc. Windows can be accessed by their title, display text, size, location, class, or internal Win32 API handles determined using the included AU3Info utility.
  • Obtaining information and interacting with controls (especially standard ones): edit field, switch, list, buttons, status bar, etc., incl. inactive.
  • Internet: reading HTML code of pages and downloading files, working with FTP , sending email messages, working with databases MySQL And SQLite.
  • Working with protocols TCP And UDP.
  • Automation in browsers: Internet Explorer , Opera , FireFox.
  • Common high-level language elements, such as working with loops.
  • A huge number of functions for working with text (strings), incl. With regular expressions in style Perl(library used PCRE).
  • Working with sound.
  • Perform complex mathematical calculations.
  • Simple syntax similar to BASIC.
  • AutoItX - merged version in the form COM And DLL, which allows you to use AutoIt capabilities in programs written in other languages.

Like other scripting languages, AutoIt is a third generation language that uses the classical model and variant type variables to store Various types data, including arrays. AutoIt lacks (or has limited support for) namespaces, object-oriented programming, abstract data types, classes, and advanced graphics functions. However, in addition to the capabilities built into the AutoIt core, you can take advantage of a large library of ready-made functions.

A popular use of AutoIt is developing utilities for Microsoft Windows. Common tasks such as website monitoring, network monitoring, disk defragmentation and backup can be automated and combined into a user-customized utility.

AutoIt is often used to create bots for online games. Bots allow you to automate some actions in games, as a result the user can achieve the desired result faster. This use of Autoit is frowned upon by the community as it gives the program a bad reputation, however several similar scripts can be found on the official forum. Using bots is considered unfair play by most AutoIt users, and you shouldn't expect much help from the community in creating them. Many community members do not consider such requests at all.

To simplify the development of graphical interfaces, there is a visual form editor Koda FormDesigner, which has a similar interface Delphi IDE. Supports visual creation and modification of all dialog elements available in AutoIt (buttons, input fields, menus, etc.)

Source AutoIt 3.1.0 in C++ is available for download in the AutoIt archive; The code for further versions is closed. AutoIt source code was used to create the language AutoHotkey. It was developed by a small team but with active support from users all over the world. Third party support includes, but is not limited to, help files, sample programs, support forums, mailing list, and utilities.

The current version of the language is available for download on the official website of the project, as well as previous releases.

Example

Hello World program:

;Displays a standard window with the name “Example”, the inscription “Hello, world!” and the "OK" button. MsgBox(0,"Example","Hello world!")

Creating a dialog box:

;Displays a dialog box with OK and Cancel buttons. If you click “OK”, exit the program. ;Tabulation in the example is for ease of reading. $WantExit=MsgBox(1,"Question","Do you want to exit the program?") If $WantExit == 1 Then Exit EndIf

Automatic launch of the Notepad program:

;Launch Notepad, write text in its window, close the program, canceling saving. Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Here is some text.") WinClose("Untitled - Notepad") WinWaitActive("Notepad") Send("!Н")

AutoIt Community

The official English-language forum is located at http://www.autoitscript.com/forum/. There, users can share their scripts and functions, receive technical support, report bugs, make ideas and suggestions, and communicate with developers.

see also

Notes

Links

Categories:

  • Appeared in 1999
  • Programming languages ​​in alphabetical order
  • Software Development Tools
  • Scripting languages

Wikimedia Foundation. 2010.

See what "AutoIt" ​​is in other dictionaries:

    Autoit- Développeur Jonathan Bennett et le groupe AutoIt Dernière version … Wikipédia en Français