AutoHotkey v1 and v2 Built-In Variable Viewer

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

AutoHotkey v1 and v2 Built-In Variable Viewer

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


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

  1. Script & Environment (who am I, where am I running?)
  2. Date & Time (the clock, sliced every way you’d want)
  3. System & User Folders (the machine and the person using it)
  4. Input, Send & Coordinate Settings (how AHK types and clicks)
  5. Hotkeys & the Running Script (what just fired, and idle time)
  6. 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.

VariableWhat it gives you
A_ScriptDirThe folder your script lives in. Build every path off this and your script works no matter where it’s saved.
A_ScriptNameJust the filename (e.g. MyTool.ahk).
A_ScriptFullPathThe full path to the script file.
A_ScriptHwndThe window handle of the script’s hidden main window.
A_AhkPathWhere the AutoHotkey.exe running your script actually lives.
A_AhkVersionThe version of AHK running (handy for “are you on v2?” checks).
A_IsCompiled1 if the script is a compiled .exe, blank otherwise.
A_ArgsAn array of command-line parameters passed to the script.
A_WorkingDirThe current working directory (can change while running).
A_InitialWorkingDirThe working directory the script STARTED in.
A_LineFileThe file containing the currently executing line.
A_LineNumberThe line number currently running. Gold for debugging.
A_ThisFuncThe name of the function currently executing.
A_AllowMainWindowWhether the main script window is allowed to open.
A_IsCriticalWhether the current thread is Critical.
A_IsPaused / A_IsSuspendedIs the underlying thread paused, or are hotkeys suspended?
A_ListLinesWhether line logging (ListLines) is on.
💡 The one that changed how I write scripts: A_ScriptDir. Stop hardcoding C:\Users\Joe\… paths. Build everything off A_ScriptDir and your script just works when you move it or share it.
; Save a log right next to the script, no hardcoded paths
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.

VariableWhat it gives you
A_NowCurrent local date+time as YYYYMMDDHH24MISS. The Swiss Army knife of timestamps.
A_NowUTCSame idea, but in UTC.
A_YYYY / A_Year4-digit year. Two names, same value.
A_MM / A_Mon2-digit month (01-12).
A_MMMShort month name (Jan, Feb…).
A_MMMMFull month name (January…).
A_DD / A_MDay2-digit day of the month (01-31).
A_DDDShort weekday (Mon, Tue…).
A_DDDDFull weekday (Monday…).
A_WDayDay of the week as a number (1 = Sunday).
A_YDayDay of the year (1-366).
A_YWeekYear and ISO week number.
A_HourHour in 24-hour format (00-23).
A_Min / A_SecMinutes and seconds, 2 digits each.
A_MSecMilliseconds (000-999).
A_TickCountMilliseconds since the PC booted. Perfect for timing how long something takes.
💡 Notice A_YYYY and A_Year are the same thing, and so are A_DD/A_MDay and A_MM/A_Mon. AHK gives you both names so your code reads however feels natural to you.
; A sortable, filename-safe timestamp, zero external code
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.

VariableWhat it gives you
A_AppData / A_AppDataCommonThe per-user (and all-users) AppData folder. Great for settings files.
A_Desktop / A_DesktopCommonThe current user’s Desktop (and the shared one).
A_MyDocumentsThe user’s Documents folder.
A_ProgramFilesThe Program Files folder.
A_Programs / A_ProgramsCommonThe Programs folder in the Start Menu.
A_StartMenu / A_StartMenuCommonThe Start Menu folder.
A_Startup / A_StartupCommonThe Startup folder. Drop a shortcut here to launch at login.
A_TempThe temp folder. Perfect for scratch files.
A_WinDirThe Windows directory (usually C:\Windows).
A_ComSpecPath to the command processor (cmd.exe).
A_ComputerName / A_UserNameThe PC name and the logged-in user’s name.
A_OSVersionThe Windows version.
A_Is64bitOS1 on 64-bit Windows.
A_IsAdmin1 if the script is running with admin rights.
A_LanguageThe system’s default language code.
A_ScreenWidth / A_ScreenHeightThe primary monitor’s size in pixels.
A_ScreenDPIScreen DPI. Matters for positioning on scaled displays.
A_PtrSize4 or 8, telling you if you’re in a 32- or 64-bit process.
💡 Real-world win: I share tools with people all over. If I saved settings to a hardcoded path, they’d break instantly on someone else’s PC. Using A_AppData means the file lands in the right spot for whoever runs it. Zero support tickets.
; Settings file that works on ANY user’s machine
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.

VariableWhat it controls / reports
A_CoordModeMouseWhether mouse coordinates are relative to the window, client, or screen.
A_CoordModePixelCoordinate mode for pixel/image searches.
A_CoordModeCaret / Menu / ToolTipCoordinate modes for the caret, menus, and tooltips.
A_SendModeThe current Send method (Input, Event, Play).
A_SendLevelThe send level, which controls whether sent input can trigger other hotkeys.
A_KeyDelay / A_KeyDelayPlayDelay between simulated keystrokes.
A_KeyDuration / A_KeyDurationPlayHow long each simulated key is held down.
A_MouseDelay / A_MouseDelayPlayDelay between mouse actions.
A_DefaultMouseSpeedThe default speed for mouse movement (0-100).
A_CursorThe type of mouse cursor currently showing (IBeam, Arrow, etc.).
A_MenuMaskKeyThe key AHK uses to mask Win/Alt from triggering menus.
A_StoreCapsLockModeWhether CapsLock state is restored after a Send.
💡 A_Cursor is a sneaky-useful one. You can check what the mouse cursor looks like to figure out if the page is still loading (a “wait” cursor) before your script charges ahead and clicks something that isn’t there yet.
; Wait until the busy cursor goes away before continuing
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.

VariableWhat it gives you
A_ThisHotkeyThe hotkey that’s currently running. Lets one function handle many hotkeys.
A_PriorHotkeyThe hotkey that fired just before this one.
A_PriorKeyThe last physical key pressed.
A_TimeSinceThisHotkey / PriorHotkeyMilliseconds since those hotkeys fired. Great for double-tap detection.
A_EndCharThe ending character that triggered the last hotstring.
A_MaxHotkeysPerInterval / A_HotkeyIntervalThe anti-runaway-hotkey throttle settings.
A_HotkeyModifierTimeoutTiming for modifier keys during sends.
A_TimeIdleMilliseconds since the user last touched keyboard or mouse.
A_TimeIdleKeyboard / A_TimeIdleMouseIdle time for just the keyboard, or just the mouse.
A_TimeIdlePhysicalIdle time ignoring simulated input (real human activity only).
A_TrayMenuThe tray menu object, so you can add your own items.
A_IconFile / A_IconNumberThe file and index of the current tray icon.
A_IconHidden / A_IconTipWhether the tray icon is hidden, and its hover tooltip text.
A_EventInfoExtra info about the event that launched the current thread.
A_IndexThe current iteration number inside a Loop. You’ll use this ALL the time.
A_ClipboardThe Windows clipboard. Read it or write to it directly.
A_LastErrorThe last Windows error code. Your first stop when a DllCall misbehaves.
💡 A_TimeIdlePhysical is brilliant for “am I still here?” automations. It ignores input your own script sends, so it only resets when a REAL human moves the mouse. Perfect for pausing a task when you step away.
; Detect a double-tap of a hotkey using the time-since variable
~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.

VariableWhat it gives you (inside the matching loop)
A_LoopFileNameThe current file’s name (in a Files loop).
A_LoopFileExtJust the extension (txt, jpg…).
A_LoopFilePath / A_LoopFileFullPathThe relative and absolute path to the file.
A_LoopFileDirThe folder the file sits in.
A_LoopFileShortName / ShortPathThe old-school 8.3 short name and path.
A_LoopFileSize / SizeKB / SizeMBFile size in bytes, KB, or MB.
A_LoopFileTimeModified / Created / AccessedThe file’s timestamps.
A_LoopFileAttribThe file’s attributes (Hidden, ReadOnly, etc.).
A_LoopFieldThe current field in a Parse loop (splitting text by a delimiter).
A_LoopReadLineThe current line in a Read-file loop.
A_LoopRegName / RegKey / RegType / RegTimeModifiedDetails about the current item in a Registry loop.
A_TitleMatchMode / A_TitleMatchModeSpeedHow AHK matches window titles (exact, contains, regex) and how fast.
A_DetectHiddenWindows / A_DetectHiddenTextWhether AHK “sees” hidden windows and hidden text.
A_WinDelay / A_ControlDelayDelays after window and control operations.
A_FileEncodingThe default text encoding for file reads and writes.
A_RegViewWhich registry view (32- or 64-bit) you’re looking at.
💡 This is where automation gets FUN. A few lines of a Files loop using these variables can rename, sort, or clean up thousands of files while you go get coffee. That’s the whole point: let the computer do the boring, repetitive work.
; Print the name and size of every .jpg in a folder
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.

Comments are closed.