AutoHotkey should do the detection, and PowerToys should handle the clean launch experience. AutoHotkey can watch for a specific Windows process, then run a custom command when that app appears. PowerToys can make the setup easier by launching the app and related tools through PowerToys Run or a pinned shortcut. Microsoft describes PowerToys as a set of utilities for power users, which fits this job well [source: Microsoft].
TLDR: The simplest setup is to run an AutoHotkey script in the background that checks for a program such as notepad.exe, then launches a command such as a backup script, log tool, or URL. For example, when Photoshop starts, the script could open a project folder and start a time tracker. If that saves 20 seconds per launch and the app opens 10 times per day, that is more than 3 minutes saved daily. PowerToys helps by giving the person a faster way to start the app and keep the workflow tidy.
How the setup works
The idea is simple. A Windows program starts. AutoHotkey sees its process name. AutoHotkey then runs another command.
That command can be almost anything:
- Open a folder
- Run a batch file
- Start a local server
- Open a website
- Launch another app
- Write to a log file
PowerToys is not the trigger engine here. AutoHotkey is better for that. PowerToys helps with the front end. It can launch tools quickly, reduce desktop clutter, and make the workflow feel less hacked together.
Image not found in postmetaWhat needs to be installed
The user needs two tools:
- AutoHotkey v2 for process detection and command execution.
- Microsoft PowerToys for quick launching and workflow polish.
AutoHotkey v2 is recommended because it is cleaner than older v1 scripts. The syntax is stricter, which is annoying at first, but it avoids weird bugs later. Honestly, it feels like the first 10 minutes are spent fixing tiny syntax mistakes. After that, it becomes much easier.
Create the AutoHotkey watcher script
The user can create a plain text file and save it as app-watcher.ahk. The script below watches for Notepad. When Notepad starts, it opens a folder and runs a custom command only once per launch.
#Requires AutoHotkey v2.0
targetProcess := "notepad.exe"
commandToRun := "cmd.exe /c echo Notepad started >> C:\Temp\app-log.txt"
folderToOpen := "C:\Projects"
wasRunning := false
SetTimer WatchApp, 1000
WatchApp() {
global targetProcess, commandToRun, folderToOpen, wasRunning
isRunning := ProcessExist(targetProcess)
if (isRunning && !wasRunning) {
Run commandToRun
Run folderToOpen
wasRunning := true
}
if (!isRunning) {
wasRunning := false
}
}
This checks once per second. That is usually enough. A shorter timer can react faster, but it may waste resources for no real gain. It drives people crazy when a “simple” automation eats CPU for no reason.
Change it for a real app
The process name must match the program. For Chrome, it might be chrome.exe. For Visual Studio Code, it is usually Code.exe. For Excel, it is EXCEL.EXE.
The easiest way to find the name is through Task Manager. The user can open the app, press Ctrl + Shift + Esc, then check the Details tab.
Then the script can be edited like this:
targetProcess := "Code.exe"
commandToRun := "C:\Scripts\start-dev-server.bat"
folderToOpen := "C:\Websites\ClientSite"
That would run a development server and open the project folder when Visual Studio Code starts.
Add PowerToys to make it smoother
PowerToys can make the workflow easier in three common ways.
- PowerToys Run: The user can press Alt + Space and launch the watched app fast.
- Keyboard Manager: The user can remap a shortcut to open a launcher script or app shortcut.
- Workspaces: The user can start a group of apps, while AutoHotkey reacts to one of them.
A nice setup is to place the AutoHotkey script in the Windows Startup folder. Then it runs when Windows starts. PowerToys Run can then open the target app on demand. The command fires only when that app starts.
Start the script with Windows
To make the watcher always active, the user can add it to the Startup folder.
- Press Win + R.
- Type shell:startup.
- Press Enter.
- Place a shortcut to app-watcher.ahk in that folder.
After the next sign-in, AutoHotkey runs the watcher in the background. If the script needs admin rights, both the watched app and script may need the same permission level. Windows can block interaction between elevated and non-elevated programs.
Common use cases
- Design app starts: Open asset folders and start a timer.
- Code editor starts: Run a local server and open documentation.
- Accounting software starts: Open a secure notes file and backup folder.
- Game starts: Switch audio devices or run a performance profile.
Tips to avoid problems
- Use full paths for scripts and files when possible.
- Test commands in Command Prompt before placing them in AutoHotkey.
- Log actions to a text file during setup.
- Avoid duplicate triggers by tracking whether the app was already running.
- Keep the script small until the basics work.
FAQ
Can PowerToys run the command by itself when an app starts?
Not in the same direct way. PowerToys is great for launching and organizing workflows, but AutoHotkey is the better tool for watching a process and reacting to it.
Does the AutoHotkey script need to stay open?
Yes. It must run in the background. Adding it to the Startup folder is the easiest fix.
Can this work with Microsoft Store apps?
Sometimes. Store apps may use different process names. Task Manager is the best place to check the exact name.
Can one script watch several programs?
Yes. The script can be expanded with more process names and commands. It is best to add one app at a time and test each one.
Is this safe?
It is safe if the commands are trusted. The user should avoid running unknown scripts, especially scripts downloaded from random forums.
