Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GhostWindow

GhostWindow — a Windows utility that hides any window from screen capture (OBS, Zoom, Discord, etc.), removes it from the taskbar and Alt+Tab, and keeps it on top of other windows.

Works by injecting a DLL into the target process and using SetWindowDisplayAffinity (Windows 10 2004+).


Features

  • Hide a window from screen capture (OBS, Zoom, Discord, Teams, etc.)
  • Remove from taskbar and Alt+Tab
  • Keep on top of other windows
  • Hotkeys — show/hide GhostWindow, pin/unpin target, bring to front
  • Pick mode with countdown timer to select a window under the cursor
  • Watchdog — automatically re-hides if the target process resets window styles
  • Cursor lock — forces the default arrow cursor on hidden windows (prevents custom cursors from appearing)
  • Restore windows individually or all at once on exit
  • Recover tracked windows after a crash using an atomic per-user journal
  • Restored/forgotten windows are excluded from automatic rediscovery, including after restart
  • The injected DLL remains loaded until the target process exits, to avoid unloading code that may still be referenced by window hooks or callbacks.

Requirements

  • Windows 10 2004+ or Windows 11
  • 64-bit Python 3.10+ and a matching 64-bit target process/DLL
  • PySide6
  • Administrator rights (for injecting into elevated or other-user processes)

Installation

git clone https://github.com/ScavyXYZ/GhostWindow.git
cd GhostWindow
python -m pip install -r requirements.txt

Building GhostWindow.dll

The DLL is already built and included in the repository. To rebuild:

./scripts/build-dll.ps1

The Python controller requires DLL version 6. Restart target applications that still have an older DLL loaded; it is not safe to replace their live hooks.

Visual Studio (MSVC)

:: x64 Native Tools Command Prompt for VS
cl /nologo /LD /O2 /EHsc /W4 GhostWindow.cpp /Fe:GhostWindow.dll /link /DEF:GhostWindow.def

MinGW-w64

g++ -O2 -shared -o GhostWindow.dll GhostWindow.cpp GhostWindow.def -luser32 -static

Usage

Running

:: Run as administrator (recommended)
python ghostwindow.py

Hiding a window

  1. Click "Pick a window" — a 5-second countdown appears
  2. Point your cursor at the target window during the countdown
  3. After selection, click "Hide"
  4. The window disappears from the taskbar, screen capture, and Alt+Tab

Showing a window again

  • Click Show for the picked target, or right-click a tracked row and choose Show this only / Show all of this process
  • Restore in the bottom bar restores the selected window and stops tracking it
  • Quit restores all tracked windows before exiting

The DLL intentionally remains loaded until the target process exits. Repeated Show/Restore calls do not reset native styles, topmost or display affinity after the original state has already been restored.

Hotkeys

Hotkey Action
Ctrl+Shift+F3 Show/hide the GhostWindow window
Ctrl+Shift+F4 Pin/unpin the selected window (toggle always-on-top)
Ctrl+Shift+F5 Bring the selected window to front
  • During pick mode, Ctrl+Shift+F3 cancels the selection

Buttons

Button Action
Pick a window Select a window under the cursor
Hide GhostWindow Hide GhostWindow itself
Hide Hide the selected window
Show Show the selected window
Bring to front Activate the selected window
Refresh Refresh the hidden windows list
Restore Restore the selected window (un-hide)
Forget Remove from the list (window stays hidden)
Quit Exit, restoring all windows

Project Structure

GhostWindow/
├── ghostwindow.py      — entry point: app setup, hotkeys, admin check
├── constants.py        — tunables, paths, hotkey labels
├── strings.py          — all user-facing text
├── applog.py           — rotating file logging
├── tasks.py            — TaskRunner (QThreadPool, per-key de-duplication)
├── hotkey.py           — global hotkey manager + native event filter
├── core/               — Win32 and domain logic (no Qt widgets)
│   ├── winapi.py       — the only place with ctypes signatures and constants
│   ├── errors.py       — typed errors and Win32 hints
│   ├── procs.py        — Process: alive, image name, module base
│   ├── windows.py      — Window: queries, stealth styling, enumeration
│   ├── injector.py     — DLL injection, remote calls, detach
│   ├── stealth.py      — StealthService: hide/show/pin/detach
│   ├── models.py       — WindowEntry, WindowState, EntryStore
│   ├── probe.py        — WindowProbe: background state snapshot
│   ├── tracking.py     — pure watchdog/retry state transitions
│   ├── journal.py      — atomic recovery journal and process identity validation
│   ├── pe.py           — resolve exports from the remote PE, including forwarders
│   └── system.py       — console hiding, admin check
├── ui/                 — Qt widgets
│   ├── main_window.py  — widget bindings and user interactions
│   ├── main_view.py    — widget construction
│   ├── session.py      — operations, watchdog, recovery and asynchronous shutdown
│   ├── table_model.py  — QAbstractTableModel for the hidden list
│   ├── titlebar.py     — frameless title bar
│   ├── picker.py       — picker overlay for window selection
│   ├── cursor_lock.py  — in-process cursor lock (forces arrow cursor)
│   └── style.qss       — dark theme
├── GhostWindow.cpp     — DLL source
├── GhostWindow.def     — DLL exports
└── GhostWindow.dll     — built DLL

The core package contains no Qt GUI code, so the WinAPI/domain logic can be tested or reused without starting an event loop. WindowSession owns the entry store and applies worker results on the GUI thread; blocking WinAPI work runs through TaskRunner on a background thread pool.


How It Works

  1. Injection — LoadLibraryW via CreateRemoteThread with the DLL path
  2. StealthHide — the DLL calls:
    • SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE) — exclude from capture
    • WS_EX_TOOLWINDOW — remove from taskbar
    • HWND_TOPMOST — keep on top
  3. StealthShow — restore the original state (styles are saved in window properties)
  4. Cursor Lock — ui/cursor_lock.py hooks WM_SETCURSOR and mouse messages on the target window and all its children, forcing the default arrow cursor. A watchdog timer (~30 ms) re-applies the cursor if Qt or the target app changes it programmatically.

Logs and troubleshooting

Runtime logs are written to %LOCALAPPDATA%\GhostWindow\ghost_debug.log (rotated at 1 MB, 3 backups). For verbose output:

set GHOSTWINDOW_DEBUG=1
python ghostwindow.py

Common issues:

  • Injection fails / access denied — restart GhostWindow as administrator. A 32-bit DLL cannot be injected into a 64-bit process, and vice versa. Windows forgotten from the list are not restored automatically. If GhostWindow crashes, restart GhostWindow to recover its tracked list, then use Show/Restore or Quit. Alternatively restart the affected application.
  • Hotkey does not work — another application already owns it; close that application or change the hotkey in the entry point and its label in constants.py. Hiding GhostWindow itself is disabled when its recovery hotkey cannot be registered.
  • "GhostWindow.dll not found" — build the DLL or place it next to ghostwindow.py.
  • Window is not hidden — UWP/Store apps and some anti-cheat protected processes reject SetWindowDisplayAffinity or DLL injection.
  • Remote call timed out — the target may be hung. Calls have a five-second wait limit. The thread and its arguments remain alive, and further mutations are blocked until it finishes. Do not force-unload the DLL.

Crash recovery

%LOCALAPPDATA%\GhostWindow\state.json records intent before hiding a window. Writes use a flushed temporary file and atomic replacement. On restart, GhostWindow checks the process creation time, window ownership and a per-window identity marker to reject reused PIDs/HWNDs. Already restored windows are not re-hidden. Only one GhostWindow instance can hold the recovery journal at a time.

Journal version 2 stores a nonzero random 63-bit marker in the fixed Win32 property GhostWindow.Identity.v2. The marker survives controller restarts and Show/Restore, but belongs to the actual window rather than its numerical HWND. Tracked commands and discovery exclusions check this marker as well as process identity. Access-denied errors preserve recovery information and block mutations. This is protection against accidental handle reuse, not against a malicious target process or an atomic guarantee against a window closing during a Win32 call.

Upgrading a version 1 journal: it has no per-window markers, so the application will preserve it and disable new hiding instead of trusting its HWNDs. Back up state.json, restart every affected target application to reset its windows, close GhostWindow, then move the old journal aside and launch GhostWindow again. Do not move the journal while affected windows are still hidden.

If the journal is corrupt or a process identity cannot be verified, new hiding is disabled instead of overwriting recovery information. Retry with administrator rights where appropriate. Otherwise back up the journal, restart the affected applications to reset their windows, and only then move the invalid journal aside. Forget deliberately removes a window from both tracking and crash recovery. The journal retains only its process/window identity as an exclusion, so the watchdog does not rediscover it after restart; it will not be restored on exit.

Development and checks

python -m venv .venv
./.venv/Scripts/python.exe -m pip install -r requirements-dev.txt
./.venv/Scripts/python.exe -m ruff check .
./.venv/Scripts/python.exe -m pyright
./.venv/Scripts/python.exe -m pytest -q
./scripts/build-dll.ps1
$env:GHOSTWINDOW_NATIVE_TESTS = "1"
./.venv/Scripts/python.exe -m pytest -q
Remove-Item Env:GHOSTWINDOW_NATIVE_TESTS

Default tests use fake process operations and offscreen Qt widgets; native tests are skipped unless explicitly enabled. Native tests create disposable windows in their own process and call the DLL directly, never injecting into other applications. They cover repeated restoration, partial failure/retry, window markers, recovery, and the controller's Hide → Show → Quit flow. The failure harness is compiled in a temporary directory; its test-only exports are not part of the shipped DLL. GitHub Actions checks Python 3.10 and 3.14 on Windows, compiles the DLL, and runs the native tests. Real OBS/Zoom capture behavior still requires an interactive Windows smoke test.


Known Limitations

  • Some anti-cheats may block DLL injection
  • UWP/Store apps may not support SetWindowDisplayAffinity
  • Administrator rights are required to inject into elevated processes

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages