KeyRoutines
ConditionFreecond.app.frontmost

Check which app is in front before a Windows 11 routine acts

App or window in front is a condition that checks whether a chosen app is the active window right now. It keeps a routine from doing something in the wrong place, for example only sending keys when your editor has focus.

How it works

  • Pick the app or game, and the condition is true while one of its windows is in the foreground.
  • In a Wait until it doesn't keep checking: it listens for Windows' own "window in front changed" signal and reacts the moment you switch.
  • When it matches, the window and process it found are passed on to later steps.
  • When it doesn't match, the reason names the app that is in front instead, which makes a run easy to read.

Routines that use it

Only in your editor

A hotkey routine starts with an If on App or window in front, so Press keys only fires its shortcut while your code editor is the active window.

Wait for the user to switch

After Open app starts a game, Wait until the game is in front, then Set default audio device moves sound to your headset.

Different action per app

One hotkey runs Media control when your music player is in front and Window state minimize for everything else.

Questions

How can a routine tell which window is active?
Use the App or window in front condition, or Get window info with "the window in front" when you need its title or position. The condition is simpler when you only need a yes or no.
Is this different from App is running?
Yes. App is running is true whenever the app is open, even in the background; this condition is only true while the app has focus.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.