Red Button of the last window quits the Application

Description of what you are sharing
Latest Update: 01.12.2023

Opt-in for Apps!
Only works for Apps you choose and add to the Conditional List. See How-to for more information.

.
What the preset is for:
If there is only one window left, the App will quit, when the red button of the window is clicked.

.
How it works:
If you want to add an Application, which should quit with the last open window, you have to do the following steps.

  1. Change in Settings > Advanced Settings > Scripting BTT
    -> Turn on "Allow external BetterTouchTool Scripting

  2. Click on the Trigger 'Leftclick Red Window Button'.
    2b. Click in this, the second Action (the one with all the conditions in it)
    2c. Click on the button 'Advanced Conditions...' (Bottom right)
    -> This is the list of all apps that will quit - with the last open window being closed.

  3. To add an app, click on the plus-button of the last item.
    -> (You can delete an item by clicking on the minus-button of the line.)

  4. Choose 'hovered_element_details'

  5. Choose 'contains'

  6. Copy the text from the Item before and change the name in-between the "..." to the name of the application you want to add. The exact name can be seen, when you hover with the mouse over the icon of the app in the Dock. It has to the correct spelling and capitals.

  7. Have a great day!

.
Screenshots:



JNB Close App.bttpreset (17.1 KB)

Version 1.4 - 01/12/23

hi this preset not working, I'm using BTT 4.017, when I installed this preset, and open TextEdit, press command+ w and the TextEdit still exist

CMD+w ist not included in this Preset. I see no need in this cause, if I can press CMD+w, I also can just use CMD+q :sweat_smile:

But if you want to trigger this script with this combination, just make a new trigger with this command and copy all the actions from the trigger of ‘left click on red button’

If TextEdit is still open after using this, be sure that you added it correctly to the list of conditions :wink:

It works in my setup every time

hi, "just make a new trigger with this command and copy all the actions from the trigger of ‘left click on red button’ " ,dont know how to do this, can you make a preset for command+w?

Try this:

Command+W.bttpreset (5.9 KB)

still not working

I installed this preset and open TextEdit, press command + w, the textEdit still exist in Command+tab view

Try one after the other after restarting BTT. Please tell me which one was the problem :blush:

  1. You need to have both presets installed

  2. Restart BTT

  3. In the Settings ‘Advanced Settings > Scripting BTT’ turn on ‘Allow external BetterTouchTool Scritping’
    (after trying CMD+w, you should see the variable ‘closeThatThing: false’ in this list)

  4. Try to reconnect the named triggers:
    Klick on the second action (in your picture) in the middle coloum with the ABC icon. Then choose from the dropdown menue on the right ‘Named Trigger > Named Trigger: Close That App’
    Do this for the fourth action also with ‘Named Trigger: Close That Window’

I hope this will do the trick
Cheers

@hu_hao did it work? And if so, what was the missing thing?

not work.
preset1 installed:

preset2 installed:

and do your 1, 2, 3, 4 steps

after cmd+ w the textEdit still exist in background😂

Great tool. thank you!
the CMD+W preset worked for me. I guess @hu_hao maybe you've duplicated trigger for CMD+W. first delete all. related presets and disable others then test it.
Although I should say this CMD+W is not perfect yet. cause it would CMD+Q in some apps like Safari which it should close just the current tab.
Another bug of this is the trigger condition depends on the location of mouse pointer (hover) so because of the keyboard shortcut it may close inactive app! (because the mouse pointing at that app's windows)
For the CMD+W version I suggest to check and trigger just on the CURRENT app. like mac OS used to be.

And there is a bug in the main "Red Button" preset as well: If you have some unsaved work on TextEdit it won't alert you before it quit it completely (although it restore from where you were after opening again)

1 Like

@jnb Can you elaborate the point of "closeThatThing" variable?
I didn't see it's checking anywhere.
And why did you close the app first and then close the windows? (not vise versa)

hi @omn_ia that variable is defined as false every time you click on the red button. If the app is listed in the conditions of 'CloseThatApp', then it will be set to 'true'. Which cancels out the next 'CloseThatWindow'. If it stays false, 'CloseThat'Window' will be executed. This is also explained at the end of my initial posting :wink:

Look in the conditions of 'CloseThatWindow'. There you'll see the condition that the variable has to be 'false'.

And this is the reason, why I call CTApp before CTWindow. The other way around would make no sense.


Thanks for your feedback on CMD+W. I do not use this. Because of the mentioned problems. The command has the purpose of closing windows, not apps.
F.e. nn the case of Safari, you won't be able to close the open tabs of the last window with this setup.
There are workarounds, but they are complicated. And it is way easier to just press Q instead of W.

And if you are already pressing a combination, I see no purpose in this to be honest.


@hu_hao I guess you should delete all that is related to this setup and reinstall the presets. It should work, like for @omn_ia

1 Like

Oh i forgot the bug with unsaved work.

This is normal behavior from the App as far as I can tell. If you edit your file and use the menu to close the file or quit the app, TextEdit does the same :wink:

If you press CMD+Q yes it will close open windows immediately even if there is an ongoing progress but if you press CMD+W (or tap on the Red button of windows) it will prompt to save the ongoing document.
With your preset when I tap on the Red button of an in-progress window it quit immediately and doesn't prompt for saving the unsaved document as it should.
It I didn't clarify this behavior right tell me to send the screenshots.
thanks

Actually it has a benefit because if you have no open windows of an app it make no sense to keep app open. I don't like CMD+Q cause its like a hammer! It will close all open windows immediately even though maybe there is some window I didn't aware of. So I prefer to close each open window (open document in TextEdit) to close one by one and in just in that situation quit the app entirely. some apps has this behavior out of the box like iTerm. If you close all of its tabs and windows it will quit as well (and didn't stay open in the background with little dot beneath of its icon)

Yeah you're right. I too like this way more. But as far as I can tell. OSX has no one way of handling that anymore. The more newer Apps from Apple close the App when you click the red Button on the last Window. But CMD-W does not as far as I know ;(

I did not really understand what your use case is. So maybe capture a screenrecoding where I can see what happens.

PS. Sorry for the delay. University did say no to free time :wink:

Hi,

I just found about your preset but it doesn't work for me, in fact it breaks my red button. Whenever I click no matter which app I'm on (and if it's in the trigger list or not) just nothing happens. Any idea how to troubleshoot this . I'm on latest Sonoma 14.1.1

First off all, THANK YOU for making this happen. With that said, I am not sure what I am doing wrong but its not working properly. It works for some apps and it dosent for others. Any ideas?

(Would also be awesome to be able to whitelist applications)