How to close all open windows at once in Windows 11 or 10

Stefan
How to close all open windows at once in Windows 11 or 10

If you work a lot with apps and have multiple windows open at the same time, you can close these windows at the same time.

Closing all windows at once helps you save time by closing all windows immediately. I imagine that if you are working with multiple displays there are even more benefits to be gained. Constantly having to search for a window and close it takes time.

By running the script below you can close all windows directly without having to search for them individually and click several times.

How to close all open windows at once in Windows 11 or 10

To create a script that will close all windows at once, you need to Download and install AutoHotKey on your computer. AutoHotKey is a free application that can connect a key combination to the execution of a script.

If you have installed the AutoHotKey app, then open the notepad.

Open notepad

In notepad copy and paste the script below.

F12::
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
winclose,%this_title%
}
Return

This script closes all windows after pressing the F12 key. If you want to change the function key to another function key, change “F12::” to, for example, “F4::” to use this function key.

If you press the function key, all open windows will be closed immediately, you will not receive a notification. Please take this into account if you are working with documents, etc. that have not yet been saved.

Click on “File” and then on “Save as”.

Save script as

First, change “Save As” to “All Files”. Then enter a clearly recognizable file name that ends in “.ahk”. Then click the “Save” button.

Read also
Find network adapter speed in Windows 11 or Windows 10

Save as ahk file

You have now created an AutoHotKey script file. Opening the file will cause it to run in the background.

Run script

You will not receive a notification of this. This script now waits until the function key is pressed. Pressing the function key will run the script and immediately close all open windows.

To manage the script you can open AutoHotKey from the system tray.

AutoHotKey in system tray

I hope this helped you. Thank you for reading!

Lees meer:


Problem solved?


Help other people too.
Share this article on a website, forum or via social media.

Join our new computer forum for questions and computer help.
Do you have a computer question?

The email address will not be published. Required fields are marked with *