Every AutoHotkey v2 Built-in Variable, Explained in Plain English

AutoHotkey hands you a pile of FREE information about the computer, the clock, and your script. Here’s what all of it means, grouped so it actually sticks.
How to Search and Examining Built-in Variables in AutoHotkey
▶ Watch the quick walkthrough of the Built-in Variable Viewer
Get the AHK v2 script here:
Here’s a little secret that took me way too long to appreciate: AutoHotkey is quietly keeping track of a ton of useful stuff for you, all the time. The date. The time. Where the user’s Desktop lives. Whether the script is running as admin. The screen size. All of it, sitting right there in built-in variables, ready to use.
You don’t have to fetch any of it. You don’t have to call an API. You just type the variable name and AHK fills in the value. That’s it.
The cool thing is, once you know these exist, you stop writing code the hard way. Need today’s date in a filename? It’s one variable. Need to save a file to the user’s Documents folder no matter whose machine it’s on? One variable. This is the kind of small stuff that saves you HUGE amounts of time over a year.
I built a little tool called the Built-in Variable Viewer that shows every one of these live, with its current value, so you can search and explore them. This page walks through all of them, grouped into 6 buckets so your brain has somewhere to put them. Now on with the show. 🚀
The 6 Groups
- Script & Environment (who am I, where am I running?)
- Date & Time (the clock, sliced every way you’d want)
- System & User Folders (the machine and the person using it)
- Input, Send & Coordinate Settings (how AHK types and clicks)
- Hotkeys & the Running Script (what just fired, and idle time)
- Loops, Windows & Text Matching (the workhorse variables)
1. Script & Environment
These answer a simple question: “Who am I and where am I running?” Any time your script needs to know something about ITSELF, this is where you look. I use these constantly for logging and for building file paths relative to the script.
| Variable | What it gives you |
|---|---|
| A_ScriptDir | The folder your script lives in. Build every path off this and your script works no matter where it’s saved. |
| A_ScriptName | Just the filename (e.g. MyTool.ahk). |
| A_ScriptFullPath | The full path to the script file. |
| A_ScriptHwnd | The window handle of the script’s hidden main window. |
| A_AhkPath | Where the AutoHotkey.exe running your script actually lives. |
| A_AhkVersion | The version of AHK running (handy for “are you on v2?” checks). |
| A_IsCompiled | 1 if the script is a compiled .exe, blank otherwise. |
| A_Args | An array of command-line parameters passed to the script. |
| A_WorkingDir | The current working directory (can change while running). |
| A_InitialWorkingDir | The working directory the script STARTED in. |
| A_LineFile | The file containing the currently executing line. |
| A_LineNumber | The line number currently running. Gold for debugging. |
| A_ThisFunc | The name of the function currently executing. |
| A_AllowMainWindow | Whether the main script window is allowed to open. |
| A_IsCritical | Whether the current thread is Critical. |
| A_IsPaused / A_IsSuspended | Is the underlying thread paused, or are hotkeys suspended? |
| A_ListLines | Whether line logging (ListLines) is on. |
LogFile := A_ScriptDir “\log.txt”
FileAppend(“Started `n”, LogFile)
; A quick “which version am I on?” guard
if A_AhkVersion < “2.0”
MsgBox(“This script needs AHK v2!”)
2. Date & Time
This is the group I reach for the most. AHK slices the current date and time into every piece you could want, already zero-padded and ready to drop into a filename or a report. No date library, no formatting headaches.
| Variable | What it gives you |
|---|---|
| A_Now | Current local date+time as YYYYMMDDHH24MISS. The Swiss Army knife of timestamps. |
| A_NowUTC | Same idea, but in UTC. |
| A_YYYY / A_Year | 4-digit year. Two names, same value. |
| A_MM / A_Mon | 2-digit month (01-12). |
| A_MMM | Short month name (Jan, Feb…). |
| A_MMMM | Full month name (January…). |
| A_DD / A_MDay | 2-digit day of the month (01-31). |
| A_DDD | Short weekday (Mon, Tue…). |
| A_DDDD | Full weekday (Monday…). |
| A_WDay | Day of the week as a number (1 = Sunday). |
| A_YDay | Day of the year (1-366). |
| A_YWeek | Year and ISO week number. |
| A_Hour | Hour in 24-hour format (00-23). |
| A_Min / A_Sec | Minutes and seconds, 2 digits each. |
| A_MSec | Milliseconds (000-999). |
| A_TickCount | Milliseconds since the PC booted. Perfect for timing how long something takes. |
Stamp := A_YYYY “-“ A_MM “-“ A_DD “_” A_Hour A_Min A_Sec
MsgBox(“Backup_” Stamp “.txt”) ; Backup_2026-07-13_172742.txt
; Time how long a chunk of code takes
Start := A_TickCount
Sleep(250)
MsgBox(“That took “ (A_TickCount – Start) ” ms”)
3. System & User Folders
This group is about the machine and the person sitting at it. The folder variables are the real heroes here. They let you write ONE script that saves files to the right place on ANY Windows machine, no matter the username or drive letter.
| Variable | What it gives you |
|---|---|
| A_AppData / A_AppDataCommon | The per-user (and all-users) AppData folder. Great for settings files. |
| A_Desktop / A_DesktopCommon | The current user’s Desktop (and the shared one). |
| A_MyDocuments | The user’s Documents folder. |
| A_ProgramFiles | The Program Files folder. |
| A_Programs / A_ProgramsCommon | The Programs folder in the Start Menu. |
| A_StartMenu / A_StartMenuCommon | The Start Menu folder. |
| A_Startup / A_StartupCommon | The Startup folder. Drop a shortcut here to launch at login. |
| A_Temp | The temp folder. Perfect for scratch files. |
| A_WinDir | The Windows directory (usually C:\Windows). |
| A_ComSpec | Path to the command processor (cmd.exe). |
| A_ComputerName / A_UserName | The PC name and the logged-in user’s name. |
| A_OSVersion | The Windows version. |
| A_Is64bitOS | 1 on 64-bit Windows. |
| A_IsAdmin | 1 if the script is running with admin rights. |
| A_Language | The system’s default language code. |
| A_ScreenWidth / A_ScreenHeight | The primary monitor’s size in pixels. |
| A_ScreenDPI | Screen DPI. Matters for positioning on scaled displays. |
| A_PtrSize | 4 or 8, telling you if you’re in a 32- or 64-bit process. |
Config := A_AppData “\MyTool\settings.ini”
; Only do the admin-only stuff if we actually have rights
if A_IsAdmin
MsgBox(“Running as admin, full power!”)
else
MsgBox(“Hi “ A_UserName “, we’re running normal.”)
4. Input, Send & Coordinate Settings
These control HOW AutoHotkey types, clicks, and measures the screen. Most of them are set by commands like SendMode or CoordMode, and the variable just lets you read back the current setting. Handy when a script “works on my machine” but you need to check why it’s misbehaving somewhere else.
| Variable | What it controls / reports |
|---|---|
| A_CoordModeMouse | Whether mouse coordinates are relative to the window, client, or screen. |
| A_CoordModePixel | Coordinate mode for pixel/image searches. |
| A_CoordModeCaret / Menu / ToolTip | Coordinate modes for the caret, menus, and tooltips. |
| A_SendMode | The current Send method (Input, Event, Play). |
| A_SendLevel | The send level, which controls whether sent input can trigger other hotkeys. |
| A_KeyDelay / A_KeyDelayPlay | Delay between simulated keystrokes. |
| A_KeyDuration / A_KeyDurationPlay | How long each simulated key is held down. |
| A_MouseDelay / A_MouseDelayPlay | Delay between mouse actions. |
| A_DefaultMouseSpeed | The default speed for mouse movement (0-100). |
| A_Cursor | The type of mouse cursor currently showing (IBeam, Arrow, etc.). |
| A_MenuMaskKey | The key AHK uses to mask Win/Alt from triggering menus. |
| A_StoreCapsLockMode | Whether CapsLock state is restored after a Send. |
while (A_Cursor = “Wait” || A_Cursor = “AppStarting”)
Sleep(100)
MsgBox(“Cursor is idle, safe to click now.”)
5. Hotkeys & the Running Script
This group is about what’s happening RIGHT NOW. Which hotkey just fired? How long has the user been idle? What’s on the clipboard? These are the variables that make your scripts feel smart and responsive.
| Variable | What it gives you |
|---|---|
| A_ThisHotkey | The hotkey that’s currently running. Lets one function handle many hotkeys. |
| A_PriorHotkey | The hotkey that fired just before this one. |
| A_PriorKey | The last physical key pressed. |
| A_TimeSinceThisHotkey / PriorHotkey | Milliseconds since those hotkeys fired. Great for double-tap detection. |
| A_EndChar | The ending character that triggered the last hotstring. |
| A_MaxHotkeysPerInterval / A_HotkeyInterval | The anti-runaway-hotkey throttle settings. |
| A_HotkeyModifierTimeout | Timing for modifier keys during sends. |
| A_TimeIdle | Milliseconds since the user last touched keyboard or mouse. |
| A_TimeIdleKeyboard / A_TimeIdleMouse | Idle time for just the keyboard, or just the mouse. |
| A_TimeIdlePhysical | Idle time ignoring simulated input (real human activity only). |
| A_TrayMenu | The tray menu object, so you can add your own items. |
| A_IconFile / A_IconNumber | The file and index of the current tray icon. |
| A_IconHidden / A_IconTip | Whether the tray icon is hidden, and its hover tooltip text. |
| A_EventInfo | Extra info about the event that launched the current thread. |
| A_Index | The current iteration number inside a Loop. You’ll use this ALL the time. |
| A_Clipboard | The Windows clipboard. Read it or write to it directly. |
| A_LastError | The last Windows error code. Your first stop when a DllCall misbehaves. |
~Ctrl::{
if (A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < 400)
MsgBox(“Double-tap detected!”)
}
; Grab whatever is on the clipboard
MsgBox(“You copied: “ A_Clipboard)
6. Loops, Windows & Text Matching
Last group, and it’s a workhorse. The A_LoopFile* variables are how you process folders full of files with almost no code, and the window/text settings control how AHK finds windows and reads them. If you automate file cleanup or app control, you’ll live here.
| Variable | What it gives you (inside the matching loop) |
|---|---|
| A_LoopFileName | The current file’s name (in a Files loop). |
| A_LoopFileExt | Just the extension (txt, jpg…). |
| A_LoopFilePath / A_LoopFileFullPath | The relative and absolute path to the file. |
| A_LoopFileDir | The folder the file sits in. |
| A_LoopFileShortName / ShortPath | The old-school 8.3 short name and path. |
| A_LoopFileSize / SizeKB / SizeMB | File size in bytes, KB, or MB. |
| A_LoopFileTimeModified / Created / Accessed | The file’s timestamps. |
| A_LoopFileAttrib | The file’s attributes (Hidden, ReadOnly, etc.). |
| A_LoopField | The current field in a Parse loop (splitting text by a delimiter). |
| A_LoopReadLine | The current line in a Read-file loop. |
| A_LoopRegName / RegKey / RegType / RegTimeModified | Details about the current item in a Registry loop. |
| A_TitleMatchMode / A_TitleMatchModeSpeed | How AHK matches window titles (exact, contains, regex) and how fast. |
| A_DetectHiddenWindows / A_DetectHiddenText | Whether AHK “sees” hidden windows and hidden text. |
| A_WinDelay / A_ControlDelay | Delays after window and control operations. |
| A_FileEncoding | The default text encoding for file reads and writes. |
| A_RegView | Which registry view (32- or 64-bit) you’re looking at. |
Loop Files, A_MyDocuments “\*.jpg” {
Total := A_LoopFileSizeMB
MsgBox(A_LoopFileName ” is “ Total ” MB”)
}
; Split a comma list and act on each piece
Loop Parse, “apple,banana,cherry”, “,”
MsgBox(“Fruit #” A_Index “: “ A_LoopField)
So there you have it, every built-in variable AutoHotkey v2 hands you, sorted into buckets that hopefully make them easier to remember.
Here’s my honest advice: don’t try to memorize this list. Just skim it once so you know roughly WHAT exists, then come back when you need something. The magic isn’t knowing all 130 by heart. It’s knowing that when you think “AHK probably already tracks that”, you’re usually right. 😊
The best way to really get comfortable with these is to watch them change live. That’s exactly why I built the Built-in Variable Viewer, so you can search, filter, and see the real current value of every one of these on YOUR machine.
Want a clear, structured path for learning AutoHotkey? Take a look at our courses at the-Automator.com/Discover. They come with a 200% money-back guarantee, so you have NOTHING to risk.


