Skip to content

lhunter3/BetterCtrlW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Better Ctrl+W

Windows 10 | 11 Version 1.0.0.1 MIT License .NET 8.0

Close any window with Ctrl+W - just like in your browser!

Better Ctrl+W Demo

Installation โ€ข How to Use โ€ข Customize โ€ข Troubleshooting โ€ข FAQ

๐ŸŽฏ What is this?

Building this because windows didnt. Universal hotkey that will Close any Windows program with Ctrl+W.

If you use a web browser, you know that Ctrl+W closes tabs instantly. But try it in Notepad, Paint, or others.. nothing happens.

Better Ctrl+W makes Ctrl+W work everywhere.

โœจ Features at a Glance

Feature What it does
๐ŸชŸ Universal Window Closing Press Ctrl+W to close any window, anywhere
๐Ÿง  Smart Exclusions Automatically skips browsers and apps that already use Ctrl+W
๐ŸŽฎ Fullscreen Protection Won't close your games or fullscreen videos
๐Ÿš€ Auto-Start Option Optionally starts with Windows - set it and forget it
โš™๏ธ Fully Customizable Easy config file to add or remove exclusions

โšก Quick Reference Guide

New to Better Ctrl+W? Start here:

  1. Download & Install โ†’ Get BetterCtrlW-Setup.exe from releases
  2. Run it โ†’ Double-click the installer, click Next a few times.
  3. Configure it โ†’ Update & reload config.
  4. Done โ†’ Universal CtrlW functionality within non-excluded apps.
  5. Optional: Auto-start โ†’ Right-click tray icon โ†’ Check "Start with Windows"

Quick Tips:

  • ๐Ÿ’ก Config File: Edit C:\Users\{username}\AppData\Local\Better Ctrl+W
  • ๐Ÿ’ก Disable: Right-click tray icon โ†’ Exit

๐Ÿ“ฅ Installation

Quick Install (3 Steps)

TL;DR: Download โ†’ Double-click โ†’ Done!

  1. Download BetterCtrlW-Setup.exe from the Releases Page โฌ‡๏ธ
  2. Run the installer (double-click the downloaded file)
  3. Click through the wizard (Next โ†’ Next โ†’ Install)

๐Ÿ“‚ Installation Location

What Where
Settings C:\Users\{username}\AppData\Local\Better Ctrl+W
Start Menu Shortcut Search "Better Ctrl+W" in Start Menu
Uninstaller Windows Settings โ†’ Apps โ†’ Installed apps

๐Ÿš€ How to Use

It Just Worksโ„ข

Once installed, nothing to configure - just start pressing Ctrl+W to close windows!

๐Ÿ’ฅ Notepad closes instantly!

โ›” Where It Doesn't Interfere

Better Ctrl+W passes through in these apps (Ctrl+W works normally):

App Type What Happens
๐ŸŒ Web Browsers Ctrl+W closes tabs (Chrome, Firefox, Edge, etc.)
๐Ÿ’ป Code Editors Ctrl+W closes tabs/files (VS Code, Notepad++, etc.)
๐Ÿ–ฅ๏ธ IDEs Normal Ctrl+W behavior preserved
๐ŸŽฎ Fullscreen Games Ignored completely (won't close your game!)
๐Ÿ“บ Fullscreen Videos Ignored (won't interrupt your movie)

System Tray Menu

Right-click the tray icon to access settings:

  • Reload Config - Reload settings after changing the config file
  • Start with Windows - Check this to run Better Ctrl+W every time you start your computer
  • Exit - Close the application

Customizing Which Apps Are Excluded

Better Ctrl+W is already configured to skip apps that use Ctrl+W for their own purposes (like closing browser tabs). But you can customize this list!

What's Already Excluded?

These apps are excluded by default, so Ctrl+W works normally in them:

  • Web Browsers: Chrome, Firefox, Edge, Brave, Opera, Vivaldi
  • Code Editors: VS Code, Visual Studio, Notepad++, Sublime Text, Atom
  • Developer Tools: PyCharm, WebStorm, IntelliJ, Eclipse, Rider
  • Microsoft Office: Word, Excel, PowerPoint, Outlook
  • Terminals: Command Prompt, PowerShell, Windows Terminal
  • Communication: Discord, Slack, Teams
  • Other: Spotify, Steam, File Explorer

How to Add or Remove Apps from the Exclusion List

Step 1: Find the Config File

The settings are stored in a file called Config.json located at:

C:\Users\{username}\AppData\Local\Better Ctrl+W

Step 2: Open It in Notepad

  1. Right-click the Better Ctrl+W tray icon โ†’ Exit (the app must be closed first)
  2. Press Windows Key + R to open Run
  3. Type: notepad "C:\Users\{username}\AppData\Local\Better Ctrl+W"
  4. Press Enter

Step 3: Edit the List

You'll see something like this:

{
  "ExcludedProcesses": [
    "chrome",
    "firefox",
    "code",
    "notepad++"
  ],
  "AutoStartupEnabled": false
}
  • To add an app: Add a line with the app's process name (see below)
  • To remove an app: Delete the line with that app's name

Step 4: Find an App's Process Name

If you want to exclude a specific app:

  1. Open the app you want to exclude
  2. Press Ctrl+Shift+Esc to open Task Manager
  3. Click the "Details" tab
  4. Find your app in the list - the "Name" column shows the process name
  5. Remove the .exe part (e.g., myapp.exe โ†’ use myapp)

Step 5: Save and Reload

  1. Save the file in Notepad (Ctrl+S)
  2. Close Notepad
  3. Start Better Ctrl+W again from the Start Menu
  4. Your changes are now active!

Example: Excluding Photoshop

If you want Ctrl+W to NOT close Photoshop windows:

  1. Open Photoshop
  2. Check Task Manager โ†’ Details tab โ†’ Find "Photoshop.exe"
  3. Add "photoshop" to the list in Config.json:
{
  "ExcludedProcesses": [
    "chrome",
    "firefox",
    "photoshop"
  ],
  "AutoStartupEnabled": false
}

โš ๏ธ Important: Don't forget the commas between items! The last item in the list should NOT have a comma.


๐Ÿ’ก Tips & Tricks

Keyboard Shortcuts Cheat Sheet

Shortcut What it does
Ctrl+W Close current window (in non-excluded apps)
Ctrl+Shift+Esc Open Task Manager (to find process names)
Windows Key + R Open Run dialog (to edit Config.json)
Alt+F4 Close window (still works as backup!)

Pro Tips

๐Ÿ’ก Create custom exclusions - If you have a work app where you don't want Ctrl+W to close windows, just add it to the config!

๐Ÿ’ก Use with AutoHotkey - Better Ctrl+W works great alongside other keyboard automation tools

๐Ÿ’ก Perfect for multi-monitor setups - Quickly close windows across all your screens

๐Ÿ’ก Great for cleaning up clutter - Have 20 File Explorer windows? Ctrl+W through them in seconds!


โ“ Frequently Asked Questions (FAQ)

Does this replace Alt+F4?

No! Alt+F4 still works exactly as before. Better Ctrl+W just gives you an additional, more convenient option.

Will this break my browser?

Absolutely not! Better Ctrl+W is pre-configured to skip all major browsers. In Chrome, Firefox, Edge, etc., Ctrl+W will continue to close tabs normally.

Can I disable it temporarily?

Yes! Just right-click the tray icon and select "Exit". Launch it again from the Start Menu when you want it back.

Does it work with keyboard shortcuts apps like AutoHotkey?

Yes! Better Ctrl+W works alongside other keyboard automation tools without conflicts.

Why can't I close some windows?

Windows protects certain system windows (like Task Manager) from being closed by third-party apps. This is a security feature built into Windows.

Does this work on Windows 11?

Yes! Works perfectly on both Windows 10 and Windows 11.

Can I use this on multiple computers?

Yes! Just install it on each computer. The config file is separate for each installation.

Is my data safe?

Absolutely. Better Ctrl+W runs completely offline, collects no data, and has no internet access. It only monitors for Ctrl+W keypresses to close windows.


๐Ÿ”ง Troubleshooting

๐Ÿšซ Nothing happens when I press Ctrl+W

Click to expand troubleshooting steps

Step 1: Check if the app is running

  • Look for the Better Ctrl+W icon in your system tray (bottom-right corner, near the clock)
  • Don't see it? Click the up arrow (^) to show hidden icons
  • Still not there? Open it from the Start Menu (search "Better Ctrl+W")

Step 2: Test in a simple app

1. Press Windows Key
2. Type "notepad"
3. Press Enter to open Notepad
4. Press Ctrl+W
5. โœ… Notepad should close instantly

Step 3: Check if you're in fullscreen

  • Better Ctrl+W won't close fullscreen windows (games, videos, presentations)
  • Press Escape or F11 to exit fullscreen, then try Ctrl+W again

Step 4: Check if the app is excluded

  • The program might be on the exclusion list (see Config.json)
  • This is normal for browsers, code editors, and terminals

๐ŸŽฏ Ctrl+W doesn't work in a specific program

The program is probably excluded - here's how to check

This is normal for browsers and code editors! They're intentionally excluded.

To check if a program is excluded:

  1. Right-click the tray icon โ†’ Exit
  2. Press Windows Key + R
  3. Type: notepad "C:\Users\{username}\AppData\Local\Better Ctrl+W"
  4. Press Enter
  5. Look for the program name in the ExcludedProcesses list
  6. Remove it if you want Ctrl+W to close that program
  7. Save (Ctrl+S) and restart Better Ctrl+W

โฑ๏ธ "Start with Windows" doesn't work

Try this fix
  1. Right-click the tray icon
  2. Make sure "Start with Windows" has a checkmark โœ…
  3. Try unchecking it, then checking it again
  4. Restart your computer to test
  5. If still not working, the registry entry might need manual attention (see developer section)

๐Ÿ”’ I can't close certain windows (Task Manager, Settings, etc.)

This is normal - Windows security feature

Some Windows system windows are protected by Windows and cannot be closed by third-party programs. This includes:

  • Task Manager
  • Windows Security
  • UAC dialogs
  • System Settings (some windows)

This is a security feature built into Windows to prevent malicious programs from closing critical system windows.

Workaround: Use Alt+F4 for these protected windows.

๐Ÿ› Something else not working?

Open an issue on GitHub with:

  • What you were trying to do
  • What happened (or didn't happen)
  • What app you were using
  • Screenshots if possible

๐Ÿ—‘๏ธ Uninstalling

Easy Uninstall (2 Methods)

Method 1: Windows Settings

1. Press Windows Key
2. Type "Add or remove programs"
3. Find "Better Ctrl+W"
4. Click โ†’ Uninstall
5. Confirm

Method 2: Settings App

Settings โ†’ Apps โ†’ Installed apps โ†’ Better Ctrl+W โ†’ โ‹ฎ โ†’ Uninstall

The uninstaller removes everything automatically including:

  • โœ… The program file
  • โœ… The configuration file
  • โœ… Start Menu shortcuts
  • โœ… Auto-startup registry entry (if enabled)

๐Ÿ”’ Privacy & Security

Is This Safe?

Yes! Better Ctrl+W is designed with privacy and security in mind.

โœ… What Better Ctrl+W Does

Feature Details
๐Ÿ”Œ Completely Offline No internet connection needed or used
๐Ÿšซ Zero Data Collection Doesn't send any information anywhere
๐Ÿ‘๏ธ Open Source All code is publicly available on GitHub for review
๐Ÿ›ก๏ธ No Admin Rights Runs with standard user permissions
๐ŸชŸ Standard Windows APIs Only uses official Windows features

๐Ÿ” What It Can Access

Better Ctrl+W can only:

  • โœ… See which window is currently active (to decide if it should close)
  • โœ… Detect when you press Ctrl+W
  • โœ… Send a "close window" command (same as clicking the X button)

๐Ÿšซ What It CANNOT Do

Better Ctrl+W cannot:

  • โŒ Read your files or documents
  • โŒ See what you're typing (except detecting Ctrl+W)
  • โŒ Access the internet or network
  • โŒ Modify other programs
  • โŒ Change Windows system settings (except its own startup entry)
  • โŒ Run without your permission

๐Ÿ” Technical Security Details

For the security-conscious (click to expand)

Permissions Used:

  • Keyboard hook (SetWindowsHookEx) - to detect Ctrl+W
  • Window enumeration (GetForegroundWindow) - to identify active window
  • Process access (GetWindowThreadProcessId) - to check exclusion list
  • Registry write (optional) - only for "Start with Windows" feature

No Network Access:

  • Does not request internet permissions
  • Does not open sockets or connections
  • Cannot send or receive data

Code Signing:

  • Future releases will include code signing for additional verification

Open Source:


๐Ÿ’ป System Requirements

Requirement Details
Operating System Windows 10 or Windows 11 (64-bit)
Disk Space ~100 MB
RAM Minimal (uses ~20-30 MB when running)
Processor Any modern CPU (no special requirements)
Dependencies None! Installer includes .NET runtime
Permissions Standard user (admin not required)

Compatibility

โœ… Works with all Windows 10 versions (build 1809 or later) โœ… Works with Windows 11 โœ… Compatible with multi-monitor setups โœ… Works alongside other keyboard automation tools โœ… Supports all keyboard layouts and languages


๐Ÿ“‹ Changelog

Version 1.0.0 (Initial Release)

โœจ Features:

  • Global Ctrl+W keyboard hook for closing windows
  • Smart exclusion system for browsers and code editors
  • Fullscreen window detection
  • System tray integration
  • Auto-startup with Windows option
  • Customizable JSON configuration
  • Inno Setup installer

๐Ÿ’– Support This Project

If Better Ctrl+W makes your life easier, consider:

  • โญ Star this repo on GitHub
  • ๐Ÿ› Report bugs or suggest features via GitHub Issues
  • ๐Ÿ“ข Share it with friends and colleagues
  • ๐Ÿ”ง Contribute code improvements or translations

Every bit helps make Better Ctrl+W better for everyone!


๐Ÿ‘จโ€๐Ÿ’ป For Developers

Building from Source

Prerequisites:

  • .NET 8.0 SDK
  • Windows 10/11
  • Inno Setup 6.0+ (for creating installer)

Quick Build:

# Clone the repository
git clone https://github.com/lhunter3/BetterCtrlW.git
cd BetterCtrlW

# Build and run
dotnet build
dotnet run

Create distributable installer:

# Build single-file executable
dotnet publish -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true

# Create installer (requires Inno Setup installed)
.\build-installer.ps1

Output: Output\BetterCtrlW-Setup.exe

See BUILD.md for detailed build instructions.

How It Works (Technical)

  1. Keyboard Hook: Uses Windows low-level keyboard hooks (SetWindowsHookEx Win32 API) to intercept Ctrl+W globally
  2. Fullscreen Detection: Compares window dimensions to monitor dimensions using GetWindowRect and GetMonitorInfo
  3. Process Detection: Gets the active window's process name via GetForegroundWindow and checks against the exclusion list
  4. Window Closing: Sends WM_CLOSE message to gracefully close the window

Decision Flow:

Ctrl+W pressed โ†’ Is fullscreen? โ†’ Yes โ†’ Ignore
                      โ†“ No
                Is excluded? โ†’ Yes โ†’ Pass through
                      โ†“ No
                Send WM_CLOSE

Project Structure

  • Program.cs - Main entry point and system tray setup
  • KeyboardHook.cs - Global keyboard hook and window closing logic
  • Win32.cs - Win32 API declarations (P/Invoke)
  • AppConfig.cs - Configuration file management
  • StartupManager.cs - Windows Registry auto-startup management
  • Config.json - User configuration (exclusion list, settings)
  • installer.iss - Inno Setup installer script
  • build-installer.ps1 - Build automation script

Contributing

Contributions are welcome! Please feel free to:

  • Report bugs or issues
  • Suggest new features
  • Submit pull requests

License

MIT License - see LICENSE file for details.

๐Ÿ› Bug Reports & Feature Requests

Found a bug or have an idea? Open an issue on GitHub!

๐Ÿ—บ๏ธ Roadmap / Future Features

Considering for future releases:

  • ๐ŸŽจ Custom tray icon
  • ๐ŸŒ Multiple language support
  • โŒจ๏ธ Customizable hotkey (not just Ctrl+W)
  • ๐Ÿ“Š Usage statistics (optional, privacy-first)
  • ๐Ÿ”„ Auto-update functionality
  • ๐ŸŽฏ Window-specific rules (e.g., "close Chrome windows but not tabs")

Have an idea? Suggest it here!


Made with โค๏ธ by Lucas Hunter

View Source Report Bug Download

If Better Ctrl+W saves you time, consider giving it a โญ on GitHub!