Skip to content

araghon007/NoFocusLoss

Repository files navigation

NoFocusLoss

This is a utility that prevents games from pausing/muting on background by making sure the unfocus message doesn't get to it.

This will break some things but uhh

Uses injection since I can't really find any other way to do what I need.

Caution

Use this utility at your own risk! This utility uses process injection.

Don't use in multiplayer games, only use in games that actually need it. Be careful which process you inject into, as it could cause a softlock, requiring a restart.

Usage

  1. Launch NoFocusLossGUI.exe

image

  1. Press Refresh. This may take a short while.

image

  1. From the list on top, select the window name of the game you want to fix. You can also type the name on your keyboard after clicking on any item for it to be selected. Magic!

NoFocusLossGUI_3Eq3gTvu8R

  1. Click on Inject

NoFocusLossGUI_hNECUefsBt

  1. Enjoy!

To revert the fix, click on the game in the bottom list and click Unload.

image

Why?

Multimonitor users

How?

Magic beyond my comprehension (I will forget how this entire repo works within a week)

Really though, it's just replacing the window's WndProc to block certain messages and detouring calls to GetForegroundWindow and SetCursorPos

Features:

  • Alt-tab during cutscenes without having to worry about them pausing or muting
  • Play games on background using a controller as long as they're using xinput and not Windows.Gaming.Input (Thanks Microsoft)
  • Bypass Unity's shit no good very bad input system that makes you unable to use controllers when the game isn't focused, even in VR
  • Stops mouse capture by disabling calls to SetCursorPos (which is a dumb way to do capture in the first place)

Limitations:

  • For now only affects the main window of the injected program

Drawbacks:

  • Injection, maybe don't use it in multiplayer games
  • While active makes it very difficult, if not impossible, to interact with window title bar elements, such as dragging, minimize/maximize and close if the game captures the mouse cursor

Tested Games:

  • Teardown
  • Alan Wake
  • Need For Speed 2015 (2016)
  • I Expect You To Die 3 (yay, this fixed controller input)
  • The Long Dark

Known Issues:

  • EA's Origin overlay appears frozen, until you try alt-tabbing which forces it to refresh

TODO:

  • Figure out automatic injection?
  • Maybe a truly global solution?
  • Try to do this with UWP apps (Yeah, good luck)
  • Add support for doing this for multiple app windows, and specifying a window you want to do this with other than the supposedly main one
  • Maybe add some way to force games that use SetCursorPos for mouse capture to use ClipCursor instead, a counter that would count the amount of SetCursorPos calls per second and then redirect?

Thanks to pretty much all the same people from my X1nput repo, since I kinda used that as a base for this, plus whoever is mentioned in the code

About

Windows utility used to prevent games from pausing on focus loss

Resources

License

Stars

Watchers

Forks

Packages

No packages published