As a long-time Windows user, I experienced the convenience of Cmd
+`
after getting a MacBook Air M1. Especially when switching between different windows within the same application, this shortcut is incredibly smooth. For Windows users, this feature isn't as straightforward—typically, you need to use Alt
+Tab
to switch between all applications, without limiting it to just a single app. This guide will show you how to achieve a similar operation using AutoHotkey 1.0, allowing you to quickly switch between windows within the same program.
Download and Install AutoHotkey 1.0
- Visit the AutoHotkey Website: Open your browser and go to the AutoHotkey official website.
- Download AutoHotkey v1.0: The website provides download links for both v1.0 and v2.0. For this guide, we need v1.0, so download v1.0.
- Install AutoHotkey: Once the download is complete, run the installer and follow the prompts to complete the installation.
Create and Save Your Script
- Create a New AHK Script File: Anywhere on your computer, right-click and choose "New" > "AutoHotkey Script". Name the script "SwitchWindows.ahk".
Alternatively, you can open a blank file using Windows Notepad. -
Copy and Paste the Script Content: Paste the following script code into the new .ahk file and save it:
; Define a hotkey, such as Alt + ` (similar to macOS Cmd + `) !`:: ; Get the PID of the current active window WinGet, currentPID, PID, A ; Get the process name of the current active window WinGet, processName, ProcessName, A ; Initialize variables nextWindow := "" foundCurrent := false ; Iterate through all windows WinGet, id, list,,, Program Manager Loop, %id% { this_id := id%A_Index% ; Get the process name of the window WinGet, thisProcess, ProcessName, ahk_id %this_id% ; Check if the window belongs to the same process and is visible if (thisProcess = processName) { ; If the current window is found, the next matching window is the target if (foundCurrent) { nextWindow := this_id break } ; Check if this is the current active window if (this_id = WinExist("A")) foundCurrent := true ; If the current window is not yet found, set the first matching window as the target if (nextWindow = "") nextWindow := this_id } } ; Switch to the target window if (nextWindow != "") WinActivate, ahk_id %nextWindow% return
Place the AHK File in a Specific Location and Set It to Run on Startup
- Place the Script in a Specific Location: Place the newly created "SwitchWindows.ahk" script in the
C:\Scripts\AHK1\
directory. - Set It to Run on Startup:
- Press
Win
+R
, typeshell:startup
, and press Enter. - In the startup folder that opens, right-click and choose "Paste Shortcut" (Windows 11 may require expanding the menu first), and paste a shortcut to the "SwitchWindows.ahk" file.
- This ensures that the script starts automatically every time you boot your computer, saving you from having to manually run it.
- Press
How to Temporarily Disable the AHK Script
If you need to temporarily disable the script, such as when you don't want the hotkeys to interfere, follow these steps:
- Find the AutoHotkey Icon in the System Tray: In the system tray at the bottom-right of the screen, you'll see a green "H" icon.
- Right-Click the Icon: Right-click the green "H" icon to open the menu, and choose "Suspend hotkeys" to pause the script. The icon will turn into an "S". Alternatively, choose "Exit" to completely close the script.
Conclusion
Using AutoHotkey 1.0, you can achieve the convenience of the macOS Cmd
+`
operation with just a few simple steps, allowing you to set it up and run it automatically.
I hope this guide helps you experience better multi-window switching in the Windows environment and boosts your productivity. Give this script a try and see how much convenience it can bring to your workflow!