Clever Geek Handbook
📜 ⬆️ ⬇️

Autohotkey

AutoHotkey is a freeware language for automating tasks in Microsoft Windows .

Autohotkey
Type ofScripting language
Author
Developer
Written on
operating system
Hardware platform
Latest version
Readable File Formats
License
Site

AutoHotkey is a programming language for scripts (scripts), adapted to the easy assignment and reassignment of hot keys , including mouse buttons and the joystick . Scripts are text files with the extension “.ahk”. The package includes a utility that allows you to "compile" them into EXE files , and run on any computer running Windows, while other files that are extracted at startup may be included in the generated file.

AutoHotkey allows you to automate Windows user tasks in a way that is impossible or difficult in other programming languages. In addition, this language is compact, self-contained and works on all versions of Windows “out of the box”.

AutoHotkey can be used to simulate keyboard, mouse and joystick actions, launch programs, change their interface, manage windows, files and folders, work with the clipboard and the registry . Commands can be invoked by hotkeys.

There are also possibilities to create a GUI , send and receive window messages, call DLL functions, and process text using regular expressions .

AutoHotkey arose as an offshoot of the AutoIt project, when its author proposed to build closer support for hot keys in AutoIt v2, but did not find understanding. So the author decided to develop his own language based on the syntax of AutoIt v2 and using some features of AutoIt v3.

Currently, the development of the original branch - AutoHotkey 1.0 (later named AutoHotkey Basic, Classic, Vanilla) - has been discontinued by its creator Chris Mallett. The official successor - AutoHotkey 1.1 (AutoHotkey_L) - is being developed by a community led by Steve Gray (Lexikos) and fincs, this version provides support for Unicode , 64-bit architecture , arrays , prototype objects , as well as COM and ActiveX controls in the GUI.

A user with the alias tinku99 has developed a custom AutoHotkey_N assembly that allows AutoHotkey to be embedded in another application or language. It provides AutoHotkey functionality that may be more difficult to implement in another language.

A user with the pseudonym HotKeyIt almost at the same time released its version of AutoHotkey_H based on AutoHotkey_N, in addition to integration via dll , it could also be used via COM . There was also an attempt to implement code protection, which was achieved thanks to cryptography and anti-debugging techniques. According to some reports, there is instability in the launch on Windows 10 .

Currently, the development of the second version has been going on for several years, and is currently in the alpha version. The syntax has been restructured in this version.

Content

About Language

Language features include:

  • Compatible with Windows XP / 2003 / Vista / 2008/7/2008 R2 / 8 / 8.1 / 2012/10
  • Version for 64-bit systems.
  • Unicode support.
  • Launch console applications and access standard I / O streams.
  • Running programs on behalf of another user.
  • Compiling the script into an EXE file.
  • Includes files in a compiled file that can be extracted at startup.
  • Compression and protection of the executable file from decompilation.
  • Creation of graphical GUIs , informational messages, information input forms.
  • Calling functions from dynamic libraries and Windows API functions.
  • Work with the Windows registry , clipboard , files (read, modify, copy, delete).
  • Work with COM objects (Component object modeling).
  • Interception and emulation of keyboard clicks and mouse clicks.
  • Working with windows (it is especially easy to work with graphic elements from Windows): moving, hiding, showing, resizing, activating, closing. Windows can be accessed by their title, displayed text, size, location, class, by internal Win32 API handles defined using the supplied WindowSpy utility.
  • Getting information and interacting with controls (especially standard ones): edit field, switch, list, buttons, status bar, etc., including inactive ones.
  • Internet: reading HTML code of pages and downloading files, working with FTP , sending E-mail messages, working with MySQL and SQLite databases .
  • Work with TCP and UDP protocols .
  • Automation of work in browsers: Internet Explorer , Opera , Firefox , Google Chrome .
  • Common elements of a high-level language, such as working with loops , functions, and variables .
  • A huge number of functions for working with text (both with strings and data arrays, as well as with individual characters), including with regular expressions in the Perl style (using the PCRE library).
  • Work with sound and music.
  • Work with complex mathematical, geometric and physical calculations (for example, with trigonometric functions ).
  • Simple syntax.
  • AutoHotkey_H - a combined version in the form of COM and DLL , allowing you to use the capabilities of AHK in programs written in other languages.
  • Optimization and automation of monotonous actions (deleting, moving temporary files, clearing cache data , downloading files).

AutoHotkey is small and does not require installation. The main file is enough for work, and for creating a script - any text editor. To run without an interpreter, the script must first be compiled .

For AutoHotkey, there is an integrated development environment called SciTE4AutoHotkey, based on the free SciTE editor. The compiler, supporting utilities, and reference materials are fully integrated, making the editor the standard environment for developers using AHK. The AHK compiler and SciTE development environment are easy to install and do not require additional configuration.

Like other scripting languages, AutoHotkey is a third-generation language that uses the classic model and variant type variables to store various types of data, including arrays.

Popular use of AutoHotkey:

  • Utility development for Microsoft Windows.
  • Monitoring websites, networks.
  • Disk defragmentation and backup .
  • Remapping keys globally or for individual programs
  • Control the mouse using the keyboard or joystick
  • Tracking the system, the automatic execution of certain actions at the request of the user.
  • Creating bots / cheats / helpers / binders for games . Bots allow you to automate some actions in games, as a result, the user can quickly achieve the desired result.

To simplify the development of graphical interfaces, there is a visual editor SmartGUI Creator.

AutoHotkey source code for all C ++ versions is available for download on GitHub.

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

Examples

Hello World Program:

  1 ;  Displays a standard window with the name "Example", the inscription "Hello world!" And the "OK" button.
 2 MsgBox , 0 , Example , Hello world !

Create a dialog box:

  1 ;  Displays a dialog box with Yes and No buttons.  If you click "Yes" - exit the program.
 2 MsgBox , 4 , Question , Want to exit the program ? 
 3 IfMsgBox , Yes
 4 ExitApp
 5 else
 6 MsgBox , Thank you for staying with us .

Notepad launch:

  1 Run , notepad .  exe

Alarm clock for 12 hours and 00 minutes:

  1 SetTimer , CheckTime , 300 ;  Setting the timer to the mark once every 300 milliseconds.
 2 return ;  End of automatic execution section.  The script pauses until the label fires.
 3
 4 CheckTime:
 5 if ( A_Hour == 12 && A_Min == 00 ) ;  If the time has come.
 6 {
 7 ToolTip , Alarm Clock .  ;  We display a message.
 8 Sleep , 3000 ;  We are waiting for 3 seconds.
 9 ToolTip ;  Hide the message.
 10 }
 11 return

Hiding / Showing the cursor when pressing Win + C.

  1 ;  Hides / Shows the mouse cursor when pressing Win + C.
 2
 3 OnExit , ShowCursor ;  At the end of the script, show the cursor.
 4 return ;  End of automatic execution section.  The script pauses until the user does something.
 five
 6 ShowCursor:
 7 SystemCursor ( "On" )
 8 ExitApp
 9
 10 #c :: SystemCursor ( "Toggle" ) ;  When you click on Win + C, we show / hide the cursor.
 eleven
 12 SystemCursor ( status : = 1 )
 13 {
 14 static AndMask , XorMask , $ , hСursor
 15 , c0 , c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8 , c9 , c10 , c11 , c12 , c13 ;  System cursor.
 16 , b1 , b2 , b3 , b4 , b5 , b6 , b7 , b8 , b9 , b10 , b11 , b12 , b13 ;  The empty cursor.
 17 , h1 , h2 , h3 , h4 , h5 , h6 , h7 , h8 , h9 , h10 , h11 , h12 , h13 ;  The default cursor descriptors.
 18 if ( status = "Init" or status = "I" or $ = "" ) ;  Initialization on first call.
 19 {
 20 $ = h ;  Active cursor by default.
 21 VarSetCapacity ( hСursor , 4444 , 1 )
 22 VarSetCapacity ( AndMask , 32 * 4 , 0xFF )
 23 VarSetCapacity ( XorMask , 32 * 4 , 0 )
 24 system_cursors = 32512 , 32513 , 32514 , 32515 , 32516 , 32642 , 32643 , 32644 , 32645 , 32646 , 32648 , 32649 , 32650
 25 StringSplit c , system_cursors , `,
 26 Loop % c0%
 27 {
 28 hСursor : = DllCall ( "LoadCursor" , "Ptr" , 0 , "Ptr" , c % A_Index% )
 29 h % A_Index% : = DllCall ( "CopyImage" , "Ptr" , hСursor , "UInt" , 2 , "Int" , 0 , "Int" , 0 , "UInt" , 0 )
 30 b % A_Index% : = DllCall ( "CreateCursor" , "Ptr" , 0 , "Int" , 0 , "Int" , 0 , "Int" , 32 , "Int" , 32 , "Ptr" , & AndMask , "Ptr" , & XorMask )
 31 }
 32 }
 33 if ( status = 0 or status = "Off" or $ = "h" and ( status < 0 or status = "Toggle" or status = "T" ))
 34 $ = b ;  Use an empty cursor.
 35 else
 36 $ = h ;  We use the system cursor.
 37	
 38 Loop % c0%
 39 {
 40 hСursor : = DllCall ( "CopyImage" , "Ptr" , % $ %% A_Index% , "UInt" , 2 , "Int" , 0 , "Int" , 0 , "UInt" , 0 )
 41 DllCall ( "SetSystemCursor" , "Ptr" , hСursor , "UInt" , c % A_Index% )
 42 }
 43 }

Example script using a graphical interface:

  1 Gui , Add , Text ,, Name :
 2 Gui , Add , Text ,, Surname :
 3 Gui , Add , Edit , vFirstName ym ;  The ym parameter launches a new column of controls.
 4 Gui , Add , Edit , vLastName
 5 Gui , Add , Button , default , OK ;  The ButtonOK label (if one exists) will be launched when the button is clicked.
 6 Gui , Show ,, Simple Input Example
 7 return ;  End of automatic execution section.  The script pauses until the user does something.
 eight
 9 ButtonOK:
 10 Gui , Submit ;  Saves user input to the associated variable of each control.
 11 MsgBox Your First Name Last Name : "% FirstName%% LastName%" .
 12 GuiClose:;  It starts when the interface is closed.
 13 ExitApp

See also

  • AutoIt
  • Powerpro
  • nnCron
  • Neo Sign 0f Misery

Notes

  1. ↑ 1 2 https://autohotkey.com/foundation/
  2. ↑ The autohotkey Open Source Project on Open Hub: Languages ​​Page - 2006.
    <a href=" https://wikidata.org/wiki/Track:Q124688 "> </a> <a href=" https://wikidata.org/wiki/Track:P1972 "> </a>
  3. ↑ Release 1.1.30.03 - 2019.

Links

  • autohotkey.com (English) - official AutoHotkey website ( mirror )
    • Documentation
      • Examples
    • Forum
      • Russian-language section
    • Forum Archive
  • AutoHotkey.net - User Projects and Archive
  • AutoHotkey 1.0 on GitHub
  • AutoHotkey_L on GitHub
  • AutoHotkey_N on GitHub
  • AutoHotkey_H on GitHub
  • Translation of documentation into Russian
  • Discussion and ready-made solutions on the Russian-language forum
  • AutoHotkey Application Automation Program Reference
Source - https://ru.wikipedia.org/w/index.php?title=AutoHotkey&oldid=101233799


More articles:

  • Andorra at the 1976 Winter Olympics
  • Green Guy (Lozovsky District)
  • Midikikenda
  • Korochansky County
  • Gray Andy
  • NGC 2286
  • NGC 2289
  • NGC 2292
  • NGC 2300
  • Deep Shadows and Brilliant Highlights

All articles

Clever Geek | 2019