
π This article includes 1 downloadable practice file β
In this article
Some shortcuts only make sense in one app: F1 opening Help in Excel is a common annoyance. #HotIf limits hotkeys to specific windows.
App-specific hotkeys
#HotIf WinActive("ahk_exe EXCEL.EXE")
F1::Send "{F2}" ; edit cell instead of Help
^+v::Send "^!v" ; Paste Special
#HotIf ; end of the Excel-only block
Find an app’s exe name with Window Spy (right-click the tray icon βΊ Window Spy).
Switch to or launch
#e::{
if WinExist("ahk_exe EXCEL.EXE")
WinActivate
else
Run "excel.exe"
}
π‘ One key per daily app (Excel, Outlook, browser, Tally) replaces endless Alt+Tab cycling.
Window control
WinMove x, y, w, h, "A" moves the active window; WinMaximize, WinMinimize, and WinSetAlwaysOnTop -1, "A" pin a calculator on top.
Where people go wrong
| Problem | Fix |
|---|---|
| Hotkey works everywhere | Missing #HotIf block |
| Doesn’t work in admin apps | Run the script as administrator too |
Practice
Run the script and try the Excel-only keys; change the window size to suit your screen.
π Practice files for this article
- β¨οΈLesson 3 script (AutoHotkey v2)Double-click to run after installing AutoHotkey v2.β¬ AHK Β· 546 B
Free to use for learning. Files with macros (.bas) are plain text β import them with Alt+F11 β File β Import File, and always test on a copy.
β¨ Ask AI about this article
Stuck on a step? Ask a question and the AI answers using this article.
Free Β· AI can be wrong