A Windows WPF application that automatically returns focus to a specified window after a defined period of inactivity.
To avoid Windows anti-focus-stealing features, the app uses a non-standard approach to bringing the target window to the foreground, which involves registering a global hotkey when the app starts and then sending ourselves that hotkey which forces Windows to allow the focus change.
- Auto-Refocus: Automatically brings a target window back to focus after keyboard/mouse/touch inactivity
- Configurable Delay: Set the refocus delay from 100ms to 30000ms (0.1 - 30 seconds)
- Auto-Targeting: Picks the target window based on rules (title/class name) which are configurable
- System Tray Integration: Minimizes to system tray instead of taskbar
- Hide Mode: Start minimized to tray with refocusing automatically enabled
- Persistent Settings: All settings are saved and restored between sessions
This app was built to help me keep Microsoft Flight Simulator focussed while using other apps alongside it, since keyboard commands and controllers don't work if the focus is lost. The default rule set is configured to target Flight Simulator, but you can change it to any window type you like.
The default rules are stored in defaultrules.json which will be found alongside the executable. The rules file is a JSON array of objects with the following properties:
- ClassName: The class name of the window to match - case sensitive, exact match
- One or more TitlePrefixes: An array of title prefixes to match (for example, one for MSFS 2024 and one for MSFS 2020)
[ { "ClassName": "AceApp", "TitlePrefixes": [ "Microsoft Flight Simulator 2024 -", "Microsoft Flight Simulator 2020 -", "Microsoft Flight Simulator -" ] } ]
If you want to customize the rules permanently, edit this file before first run. After first run, the rules in use are saved to the settings.json file and you can change them there if you need to.
Title matching is case sensitive and partial - the actual window title only needs to start with one of the prefixes. This allows for dynamic titles that may include version numbers or other changing information, which is the case for Microsoft Flight Simulator.
-
Launch the application
- The app will tell you that no target window is available if you haven't launched the target app yet
-
Launch the target application/window that you want to keep focused (by default Microsoft Flight Simulator 2024/2020)
- FocusPuller should notice and start tracking it
-
Set Refocus Delay
- Use the slider to adjust the delay (100-30000 milliseconds) or type directly into the box + ENTER
- This is how long the app waits after the last user input before refocusing
-
Enable Refocusing
- Click the refocusing button to start auto-refocus
-
Configure Hide Mode (optional)
- Check "Hide Mode" if you want the app to start minimized with refocusing enabled on next launch
- This is useful for automatic startup scenarios
-
Minimize to Tray
- The app minimises to the system tray instead of the taskbar
- Right-click the system tray icon to restore or exit
Settings are automatically saved as they change to:
%APPDATA%\FocusPuller\settings.json
- Refocus delay
- Target window (title and class name)
- Refocusing enabled/disabled state
- Hide mode preference
- Target window selection rules
- HotKey configuration (default is CTRL+ALT+SHIFT+0)
You can modify the hot key configuration but you must specify at least one modifier key (CTRL, ALT, SHIFT).
- Framework: .NET 10 (Windows)
- UI: WPF
- Dependencies: Hardcodet.NotifyIcon.Wpf (for system tray support)
You can open the project in Visual Studio or build from the command line:
cd src/FocusPuller
dotnet restore
dotnet builddotnet run --project src/FocusPuller/FocusPuller.csprojOr run the compiled executable from:
src/FocusPuller/bin/Debug|Release/net10.0-windows/FocusPuller.exe
(use Debug or Release depending on which version you built).
Because Windows has anti-focus-stealing measures, refocusing may not work in some scenarios, especially if the user has recently interacted with other applications. You may see the target app icon flash in the taskbar when refocusing is attempted but blocked.
The app uses a non-standard approach to bringing the target window to the foreground. This approach is tested to work with Microsoft Flight Simulator 2024/2020 on Windows 11 25H2, but may not work with all applications, and may be affected by future simulator updates or Windows system updates.
- The target window must remain open for refocusing to work
- If the target window is closed, refocusing is automatically disabled
- If the target window becomes available again, refocusing is re-enabled automatically in hide mode only
- Refocusing only happens once the configured delay time has passed since focus was lost and there has been no user input for the configured delay time, which might exceed the configured delay time in total