Skip to content

Repository files navigation

WinFocus: highlight the active monitor and focused window on Windows

WinFocus is a free, open-source Windows utility that shows which monitor and which window currently have keyboard focus on a multi-monitor setup. It draws a thin colored border around the active monitor and a second border around the active window, so you always know where your typing will go.

WinFocus on a two-monitor desktop: an orange border marks the monitor with keyboard focus and an azure border marks the focused window

Illustration of the default look: 3 px orange monitor border, 2 px azure window border. Colors and widths are configurable.

  • Monitor frame: an orange border around the monitor that holds the focused window.
  • Window frame: an azure border around the focused window itself, hidden while that window is maximized or fullscreen.

Both borders follow keyboard focus instantly. They are click-through, never take focus, and never appear in the taskbar or Alt-Tab. There is no tray icon, no settings window, and no background service: one small native executable (about 150 KB) and nothing else.

Works on Windows 10 and Windows 11 with two, three, or more monitors, any mix of resolutions, and any DPI scaling.

Who is it for?

  • Anyone with dual or triple monitors who keeps typing into the wrong screen.
  • Keyboard-driven users (Alt-Tab, Win+Arrow, tiling tools) who want a visible focus indicator without a mouse cursor.
  • Developers and traders with several terminals, IDEs, or dashboards open at once.
  • Users who find Windows' default active-window highlighting too subtle, especially with dark themes or borderless apps.

Install

With winget

winget install rhrusha.WinFocus
winfocus --install

Approve the administrator prompt. The borders appear immediately and return automatically every time you sign in.

The winget package is a portable install: winget places winfocus.exe in its packages folder and adds winfocus to your PATH. (Until the package is accepted into the winget community repository, use the manual install below.)

Manually

  1. Download winfocus.exe from the latest release, or build it yourself (see below). Put it somewhere permanent, for example C:\Tools\WinFocus\winfocus.exe.

  2. Open a terminal in that folder and run:

    winfocus.exe --install
    
  3. Approve the administrator prompt.

There are no other files, registry settings, or services.

Uninstall and upgrade: order matters

The scheduled task points at the exe, and Windows will not let winget replace or delete an exe that is running. Always stop WinFocus first:

winfocus --uninstall        # stops it and removes the scheduled task
winget uninstall rhrusha.WinFocus

To upgrade through winget:

winfocus --stop
winget upgrade rhrusha.WinFocus
winfocus --install          # re-creates the task, starts the new version

If you upgrade without stopping first, winget reports that the file is in use; run winfocus --stop and try again. For a manual install, winfocus.exe --uninstall then deleting the exe is all there is.

What does --install do?

It creates a hidden Scheduled Task named WinFocus that starts the exe at your logon with highest privileges. Highest privileges are needed so the borders can also be drawn above elevated windows such as Task Manager or an administrator terminal. The task points at the exe's current location, so if you move the exe, run --install again from the new place.

Usage

winfocus.exe [options]             run until --stop (no autostart)
winfocus.exe --stop                stop the running instance
winfocus.exe --install [options]   start at logon (asks for admin)
winfocus.exe --uninstall           remove autostart and stop
winfocus.exe --help
winfocus.exe --version

Options (widths are 0..20 physical pixels, 0 turns that border off):

--color RRGGBB          monitor frame color     (default FF8C00)
--width N               monitor frame width     (default 3)
--window-color RRGGBB   window frame color      (default 00A8FF)
--window-width N        window frame width      (default 2)

Examples:

winfocus.exe --install --color 00FF00 --width 2         green 2 px monitor border
winfocus.exe --install --window-width 0                 monitor border only
winfocus.exe --install --width 0 --window-color FF00FF  window border only, magenta

Options given to --install are saved in the task. Running --install again replaces the previous settings.

The exe is a windowed program, so when you run it from a terminal the prompt may come back before its output is printed. In cmd, start /wait winfocus.exe --stop waits for it. When there is no terminal, results appear in a message box.

How does it work?

WinFocus is written in C against the Win32 API with no frameworks or runtimes.

  • Each border is made of four tiny layered, topmost, click-through windows, one per edge. Moving a border is four window moves; nothing is repainted, so there is no flicker under the Desktop Window Manager.
  • Focus changes, window moves and resizes, and display changes arrive through Windows accessibility events (SetWinEventHook). Nothing is polled. The process sleeps between events and uses a few megabytes of memory.
  • The window border is placed just outside the window's visible edge, taken from the DWM extended frame bounds, so it never covers content. Where the window touches a monitor edge (for example after snapping with Win+Left), that side is drawn just inside the window so it stays visible.
  • The window border is hidden while the focused window is maximized, fullscreen, the desktop, or the taskbar. The monitor border is hidden only for fullscreen windows (fullscreen video, an F11 browser, a game), so nothing is drawn over them.
  • The exe is per-monitor DPI aware, so widths are exact physical pixels on every screen.
  • Only one instance runs at a time. Extra launches exit silently.

FAQ

Does Windows have a built-in way to highlight the active monitor? No. Windows 10 and 11 have no setting that marks which monitor has keyboard focus. The active window gets a one-pixel accent border at most, which is easy to miss on large or dark displays. WinFocus fills that gap.

Is this a Windows service? No. A true Windows service runs in Session 0 and cannot draw on your desktop. WinFocus runs as a hidden per-user process started by a Scheduled Task at logon, which gives the same "always on" behavior without a service.

Does it slow down games or video? No. It reacts only to focus and window events and draws nothing while a fullscreen application has focus.

Does it work with multiple monitors at different DPI scaling? Yes. The program is per-monitor DPI aware (PerMonitorV2), so a 3 px border is 3 physical pixels on a 4K display and on a 1080p display alike.

Does it work above elevated (administrator) windows? Yes, when installed with --install, which runs it with highest privileges. When started by hand without administrator rights, the borders may not follow elevated windows.

Can I change the colors and thickness? Yes, with --color, --width, --window-color, and --window-width. Width 0 turns a border off, so you can keep only the monitor border or only the window border.

Does it need .NET, Visual C++ redistributables, or an installer? No. It is a single statically linked native exe with no dependencies.

Is it safe? Why the administrator prompt? The prompt appears only for --install and --uninstall, to create or delete the Scheduled Task. The source is a single C file you can read in a few minutes and build yourself.

How do I stop or remove it? winfocus.exe --stop stops it until next logon. winfocus.exe --uninstall removes the autostart task and stops it.

Build from source

Requirements: Visual Studio 2022 Build Tools (or Visual Studio) with the "Desktop development with C++" workload. No other dependencies.

build.cmd

Output: bin\winfocus.exe, about 150 KB, statically linked.

build_debug.cmd builds the same exe with event logging to %TEMP%\winfocus_debug.log, one line per focus, show, or move event and per frame update. Useful when some application's border misbehaves.

Project layout

src/winfocus.c          the whole program
src/version.h           version number (used by --version, the exe resource, winget)
src/winfocus.manifest   per-monitor DPI awareness
src/winfocus.rc         embeds the manifest and the version resource
build.cmd               release build
build_debug.cmd         build with event logging
winget/manifests/       winget package manifests, one folder per version
docs/design/            design notes

Releasing a new version

  1. Bump the four values in src/version.h.
  2. build.cmd, then create a GitHub release tagged vX.Y.Z with bin\winfocus.exe attached.
  3. Copy winget/manifests/r/rhrusha/WinFocus/<previous>/ to a new version folder, update PackageVersion, InstallerUrl, ReleaseDate, ReleaseNotesUrl, and InstallerSha256 (from Get-FileHash bin\winfocus.exe). Check with winget validate <folder>.
  4. Submit the folder to microsoft/winget-pkgs, for example with wingetcreate update rhrusha.WinFocus -u <exe url> -v X.Y.Z --submit.

Testing

There is no automated test suite; the program is a thin layer over Win32 window management and is verified by hand. After a change, walk through:

  1. Focus windows on each monitor: the monitor border follows immediately.
  2. Focus a normal window: the window border hugs its edge. Move and resize it: the border follows.
  3. Snap a window to a screen edge: the window border stays visible on that side.
  4. Maximize the focused window: the window border disappears, the monitor border stays. Restore it: the window border returns.
  5. Monitors with different DPI scaling: both borders are exactly N physical pixels on each.
  6. Fullscreen video or an F11 browser: both borders disappear; they return after Esc.
  7. Focus an elevated app such as Task Manager: borders still visible when running from the installed task.
  8. Click on a border: the click reaches the window underneath.
  9. Alt-Tab and the taskbar show no WinFocus entry.
  10. Unplug or plug in a monitor: no crash; the borders land on a valid monitor.
  11. --stop ends the process; a second launch exits silently.
  12. --install creates the task and survives a reboot; --uninstall removes it and stops the process.

Keywords

active monitor indicator, focused window border, highlight active window, which monitor has focus, multi-monitor focus indicator, dual monitor keyboard focus, active window highlighter, Windows 11 focus border, Windows 10 active screen highlight, screen edge border, window frame overlay.

License

MIT. See LICENSE.

About

Highlights the active monitor and focused window on Windows with thin colored borders. Native Win32, single exe, no tray icon, no service.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages